468,491 Members | 2,010 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,491 developers. It's quick & easy.

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 5592
You can use System.Math.Round

or you can use

String.Format
"Amjad" <an*******@discussions.microsoft.com> wrote in message
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
"Amjad" <an*******@discussions.microsoft.com> wrote in message
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
"Amjad" <an*******@discussions.microsoft.com> wrote in message
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.

Similar topics

3 posts views Thread by Oswald | last post: by
2 posts views Thread by westjon64 | last post: by
6 posts views Thread by Donal McWeeney | last post: by
17 posts views Thread by seb.haase | last post: by
13 posts views Thread by jamesonang | last post: by
8 posts views Thread by =?Utf-8?B?a2FyaW0=?= | last post: by
3 posts views Thread by gieforce | last post: by
reply views Thread by theflame83 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.