471,071 Members | 970 Online

# Division in 2 decimals

How can I display the result of a division operation in 2 dicimal digits only?

e.g.
Dim MyValue As Double = 10 / 3 ' Returns 3.333333, I'd like to get 3.33

Thanks

Nov 20 '05 #1
4 5744
You can use System.Math.Round

or you can use

String.Format
news:98**********************************@microsof t.com...
How can I display the result of a division operation in 2 dicimal digits only?
e.g.
Dim MyValue As Double = 10 / 3 ' Returns 3.333333, I'd like to get 3.33

Thanks

Nov 20 '05 #2
news:98**********************************@microsof t.com...
How can I display the result of a division operation in 2 dicimal digits only?
e.g.
Dim MyValue As Double = 10 / 3 ' Returns 3.333333, I'd like to get 3.33

Thanks

Use Math.Round

Dim MyValue As Double = Math.Round(10 / 3, 2)

Erik
Nov 20 '05 #3
or...

dim value as Double.
value.ToString("N2") --> 123,456.78
dominique
news:98**********************************@microsof t.com...
How can I display the result of a division operation in 2 dicimal digits only?
e.g.
Dim MyValue As Double = 10 / 3 ' Returns 3.333333, I'd like to get 3.33

Thanks

Nov 20 '05 #4
* "=?Utf-8?B?QW1qYWQ=?=" <an*******@discussions.microsoft.com> scripsit:
How can I display the result of a division operation in 2 dicimal digits only?

e.g.
Dim MyValue As Double = 10 / 3 ' Returns 3.333333, I'd like to get 3.33

\\\
Dim d As Double = 1234.5678
MsgBox(d.ToString("N2"))
MsgBox(String.Format("{0:N2}", d))
MsgBox(Math.Round(d, 2).ToString())
....
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

### This discussion thread is closed

Replies have been disabled for this discussion.