Search code examples
vb.netdecimalmath.round

vb.net Math.Round drops last 0 in price?


I am using a Math.Round function in my program as follows

Math.Round((ProductWeightByType * 4.18), 2)

This works perfect except for when the last character is already a 0 then it drops that 0 so example $1.70 becomes $1.7

How do i fix this?


Solution

  • you should try using string format, something like this could do what you need:

    String.Format("{0:C2}", Math.Round((ProductWeightByType * 4.18), 2))