Monday, March 26, 2012

Text Format for Decimal

I'm grabbing "Amount" from a DB with Decimal format. The outpul of
AmountL.Text comes up as 9999999.99 and I want to format this so it is
displayed as 9,999,999.99. Can someone help me with this simple task?

AmountL.Text = dr.Item("Amount")

Thanks!

PhilOn Oct 8, 8:35 pm, "pvong" <phillip*at*yahoo*dot*comwrote:

Quote:

Originally Posted by

I'm grabbing "Amount" from a DB with Decimal format. The outpul of
AmountL.Text comes up as 9999999.99 and I want to format this so it is
displayed as 9,999,999.99. Can someone help me with this simple task?
>
AmountL.Text = dr.Item("Amount")


Hi Phil

try to format String.Format("{0:0,0}", dr.Item("Amount"));
"pvong" <phillip*at*yahoo*dot*comwrote in message
news:ettLZmdCIHA.4176@.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

I'm grabbing "Amount" from a DB with Decimal format. The outpul of
AmountL.Text comes up as 9999999.99 and I want to format this so it is
displayed as 9,999,999.99. Can someone help me with this simple task?
>
AmountL.Text = dr.Item("Amount")


AmountL.Text = dr.Item("Amount").ToString("#,##0.00")

--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Mark,
I'm getting this error message.
Input string was not in a correct format.
I'm trying to do this in VB.Net

"Mark Rae [MVP]" <mark@.markNOSPAMrae.netwrote in message
news:uRjwv5dCIHA.5600@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:ettLZmdCIHA.4176@.TK2MSFTNGP06.phx.gbl...
>

Quote:

Originally Posted by

>I'm grabbing "Amount" from a DB with Decimal format. The outpul of
>AmountL.Text comes up as 9999999.99 and I want to format this so it is
>displayed as 9,999,999.99. Can someone help me with this simple task?
>>
>AmountL.Text = dr.Item("Amount")


>
AmountL.Text = dr.Item("Amount").ToString("#,##0.00")
>
>
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


This is almost perfect. It cuts off my pennies. How do I get it to include
the 2 digits after the decimal?

"Alexey Smirnov" <alexey.smirnov@.gmail.comwrote in message
news:1191870335.161972.326090@.k79g2000hse.googlegr oups.com...

Quote:

Originally Posted by

On Oct 8, 8:35 pm, "pvong" <phillip*at*yahoo*dot*comwrote:

Quote:

Originally Posted by

>I'm grabbing "Amount" from a DB with Decimal format. The outpul of
>AmountL.Text comes up as 9999999.99 and I want to format this so it is
>displayed as 9,999,999.99. Can someone help me with this simple task?
>>
>AmountL.Text = dr.Item("Amount")


>
Hi Phil
>
try to format String.Format("{0:0,0}", dr.Item("Amount"));
>
>


On Oct 8, 9:27 pm, "pvong" <phillip*at*yahoo*dot*comwrote:

Quote:

Originally Posted by

This is almost perfect. It cuts off my pennies. How do I get it to include
the 2 digits after the decimal?
>
"Alexey Smirnov" <alexey.smir...@.gmail.comwrote in message
>
news:1191870335.161972.326090@.k79g2000hse.googlegr oups.com...
>
>
>

Quote:

Originally Posted by

On Oct 8, 8:35 pm, "pvong" <phillip*at*yahoo*dot*comwrote:

Quote:

Originally Posted by

I'm grabbing "Amount" from a DB with Decimal format. The outpul of
AmountL.Text comes up as 9999999.99 and I want to format this so it is
displayed as 9,999,999.99. Can someone help me with this simple task?


>

Quote:

Originally Posted by

Quote:

Originally Posted by

AmountL.Text = dr.Item("Amount")


>

Quote:

Originally Posted by

Hi Phil


>

Quote:

Originally Posted by

try to format String.Format("{0:0,0}", dr.Item("Amount"));- Hide quoted text -


>
- Show quoted text -


{0:0,0.00}
"pvong" <phillip*at*yahoo*dot*comwrote in message
news:eGbLO$dCIHA.464@.TK2MSFTNGP02.phx.gbl...

[top-posting corrected]

Quote:

Originally Posted by

"Mark Rae [MVP]" <mark@.markNOSPAMrae.netwrote in message
news:uRjwv5dCIHA.5600@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

>"pvong" <phillip*at*yahoo*dot*comwrote in message
>news:ettLZmdCIHA.4176@.TK2MSFTNGP06.phx.gbl...
>>

Quote:

Originally Posted by

>>I'm grabbing "Amount" from a DB with Decimal format. The outpul of
>>AmountL.Text comes up as 9999999.99 and I want to format this so it is
>>displayed as 9,999,999.99. Can someone help me with this simple task?
>>>
>>AmountL.Text = dr.Item("Amount")


>>
>AmountL.Text = dr.Item("Amount").ToString("#,##0.00")


Quote:

Originally Posted by

I'm getting this error message.
Input string was not in a correct format.
I'm trying to do this in VB.Net


AmountL.Text = Convert.ToDecimal(dr.Item("Amount")).ToString("#,##0.00")

--
Mark Rae
ASP.NET MVP
http://www.markrae.net
PERFECT!!!!

Thanks!
Phil

"Alexey Smirnov" <alexey.smirnov@.gmail.comwrote in message
news:1191871744.302099.71660@.22g2000hsm.googlegrou ps.com...

Quote:

Originally Posted by

On Oct 8, 9:27 pm, "pvong" <phillip*at*yahoo*dot*comwrote:

Quote:

Originally Posted by

>This is almost perfect. It cuts off my pennies. How do I get it to
>include
>the 2 digits after the decimal?
>>
>"Alexey Smirnov" <alexey.smir...@.gmail.comwrote in message
>>
>news:1191870335.161972.326090@.k79g2000hse.googlegr oups.com...
>>
>>
>>

Quote:

Originally Posted by

On Oct 8, 8:35 pm, "pvong" <phillip*at*yahoo*dot*comwrote:
>I'm grabbing "Amount" from a DB with Decimal format. The outpul of
>AmountL.Text comes up as 9999999.99 and I want to format this so it is
>displayed as 9,999,999.99. Can someone help me with this simple task?


>>

Quote:

Originally Posted by

>AmountL.Text = dr.Item("Amount")


>>

Quote:

Originally Posted by

Hi Phil


>>

Quote:

Originally Posted by

try to format String.Format("{0:0,0}", dr.Item("Amount"));- Hide quoted
text -


>>
>- Show quoted text -


>
{0:0,0.00}
>


Perfect! Thanks!

"Mark Rae [MVP]" <mark@.markNOSPAMrae.netwrote in message
news:urfl%23EeCIHA.1188@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:eGbLO$dCIHA.464@.TK2MSFTNGP02.phx.gbl...
>
[top-posting corrected]
>

Quote:

Originally Posted by

>"Mark Rae [MVP]" <mark@.markNOSPAMrae.netwrote in message
>news:uRjwv5dCIHA.5600@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

>>"pvong" <phillip*at*yahoo*dot*comwrote in message
>>news:ettLZmdCIHA.4176@.TK2MSFTNGP06.phx.gbl...
>>>
>>>I'm grabbing "Amount" from a DB with Decimal format. The outpul of
>>>AmountL.Text comes up as 9999999.99 and I want to format this so it is
>>>displayed as 9,999,999.99. Can someone help me with this simple task?
>>
>>>AmountL.Text = dr.Item("Amount")
>>>
>>AmountL.Text = dr.Item("Amount").ToString("#,##0.00")


>

Quote:

Originally Posted by

>I'm getting this error message.
>Input string was not in a correct format.
>I'm trying to do this in VB.Net


>
AmountL.Text = Convert.ToDecimal(dr.Item("Amount")).ToString("#,##0.00")
>
>
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

0 comments:

Post a Comment