Division in 2 decimals

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Amjad said:
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
 
* "=?Utf-8?B?QW1qYWQ=?= said:
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())
....
///
 
Back
Top