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.

Re: Display 2 decimal point by Herfried

Herfried
Fri Jul 04 20:18:44 CDT 2008

"wrytat" <wrytat@discussions.microsoft.com> schrieb:
> 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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Re: Display 2 decimal point by wrytat

wrytat
Fri Jul 04 21:36:00 CDT 2008

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?

"Herfried K. Wagner [MVP]" wrote:

> "wrytat" <wrytat@discussions.microsoft.com> schrieb:
> > 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.
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
>
>

Re: Display 2 decimal point by Jack

Jack
Sat Jul 05 00:38:37 CDT 2008

On Fri, 4 Jul 2008 17:54:00 -0700, wrytat
<wrytat@discussions.microsoft.com> wrote:

>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.?

Re: Display 2 decimal point by Herfried

Herfried
Sat Jul 05 13:35:51 CDT 2008

"wrytat" <wrytat@discussions.microsoft.com> schrieb:
> 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"))
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Re: Display 2 decimal point by wrytat

wrytat
Wed Jul 09 19:31:01 CDT 2008

Hi

Mainly displaying it at DataGridViews and Textboxes.

Thank you.

"Jack Jackson" wrote:

> On Fri, 4 Jul 2008 17:54:00 -0700, wrytat
> <wrytat@discussions.microsoft.com> wrote:
>
> >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.?
>

Re: Display 2 decimal point by wrytat

wrytat
Wed Jul 09 19:59:01 CDT 2008

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.

"Herfried K. Wagner [MVP]" wrote:

> "wrytat" <wrytat@discussions.microsoft.com> schrieb:
> > 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"))
> ///
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
>
>

Re: Display 2 decimal point by Patrice

Patrice
Thu Jul 10 06:54:05 CDT 2008

Have you tried to see what DataGridView.Columns ? You should find a
FormatString that allows to tell whihc format you wan to apply to the
column...

--
Patrice

"wrytat" <wrytat@discussions.microsoft.com> a écrit dans le message de
groupe de discussion : DEE56F25-49C5-40DF-95B8-2BC2935FD8CB@microsoft.com...
> 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.
>
> "Herfried K. Wagner [MVP]" wrote:
>
>> "wrytat" <wrytat@discussions.microsoft.com> schrieb:
>> > 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"))
>> ///
>>
>> --
>> M S Herfried K. Wagner
>> M V P <URL:http://dotnet.mvps.org/>
>> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
>>
>>