Display 2 decimal point

  • Thread starter Thread starter wrytat
  • Start date Start date
W

wrytat

How do you display a double value in 2 decimal point?

For e.g., the value 2.2, I want to display it as 2.20 instead of 2.2. I
tried System.Math.Round(thevalue,2), but it still display the value as 2.2
and not 2.20.

I using .NET 2.0 Framework, Visual Basic. Thank you.
 
wrytat said:
How do you display a double value in 2 decimal point?

For e.g., the value 2.2, I want to display it as 2.20 instead of 2.2. I
tried System.Math.Round(thevalue,2), but it still display the value as 2.2
and not 2.20.

Take a look at the overloads of 'thevalue.ToString' accepting a format
string.
 
Hi

Thank you for the reply. But I don't really understand what you mean. Do you
mean that I have to define a format of the value? How do you do that?
 
How do you display a double value in 2 decimal point?

For e.g., the value 2.2, I want to display it as 2.20 instead of 2.2. I
tried System.Math.Round(thevalue,2), but it still display the value as 2.2
and not 2.20.

I using .NET 2.0 Framework, Visual Basic. Thank you.

Where are you displaying the value? In a TextBox, in a message, etc.?
 
wrytat said:
Thank you for the reply. But I don't really understand what you mean. Do
you
mean that I have to define a format of the value? How do you do that?

\\\
Dim d As Double = 1234.5678
MsgBox(d.ToString("N2"))
///
 
Thank you very much. I've tried that with Textboxes, and it works! But can I
do it with DataGridView as well?

Thank you once again.
 
Back
Top