all groups > vb.net > may 2004 >
You're in the

vb.net

group:

rounding decimal place..


rounding decimal place.. Ken
5/31/2004 9:26:02 PM
vb.net:
HI all

I would like to round up a double number, for example, 100.689 and round up to 100.6
i know i can do it with Round function. However, it doesn't show the any decimal place if the number is 100. I would like to show the decimal places even though they are 100.00.

Re: rounding decimal place.. Jay B. Harlow [MVP - Outlook]
6/1/2004 12:13:28 AM
Ken,
Have you looked at formatting the number for display?

Depending on where you are displaying the number how you format it may
change. However the format string itself will remain the same...

Review the "Formatting Types" section of MSDN.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconformattingtypes.asp

Specifically Standard Numeric Format Strings:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconstandardnumericformatstrings.asp

For example, you can pass one of the above format strings to the
Double.ToString method.

Dim d As Double = 100.689
Dim s As String = d.ToString("N2")

Hope this helps
Jay

[quoted text, click to view]
decimal place if the number is 100. I would like to show the decimal places
even though they are 100.00.
[quoted text, click to view]

AddThis Social Bookmark Button