(vb.net) rounding to 2 decimal places

后端 未结 2 1558
一向
一向 2021-01-16 21:54

I am creating a program for a project that will help me learn visual basic. But when I work out how much a certain material is worth with dimensions. It come out with more t

相关标签:
2条回答
  • 2021-01-16 22:43

    You can use;

    Math.Round([DECIMAL], 2)
    

    If you want to round up you can use;

    MidpointRounding.AwayFromZero
    

    As an additional parameter to make;

    Math.Round([DECIMAL], 2, MidpointRounding.AwayFromZero)
    

    Hope it helps!

    0 讨论(0)
  • 2021-01-16 22:51

    The Decimal.Round method will do the trick for you. You can specify the number of decimal places.

    0 讨论(0)
提交回复
热议问题