Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

Text Format for Decimal

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pvong - 08 Oct 2007 19:35 GMT
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!

Phil
Alexey Smirnov - 08 Oct 2007 20:05 GMT
> 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 - 08 Oct 2007 20:27 GMT
This is almost perfect.  It cuts off my pennies.  How do I get it to include
the 2 digits after the 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
[quoted text clipped - 5 lines]
>
> try to format String.Format("{0:0,0}", dr.Item("Amount"));
Alexey Smirnov - 08 Oct 2007 20:29 GMT
> This is almost perfect.  It cuts off my pennies.  How do I get it to include
> the 2 digits after the decimal?
[quoted text clipped - 10 lines]
>
> - Show quoted text -

{0:0,0.00}
pvong - 08 Oct 2007 20:42 GMT
PERFECT!!!!

Thanks!
Phil

>> This is almost perfect.  It cuts off my pennies.  How do I get it to
>> include
[quoted text clipped - 14 lines]
>
> {0:0,0.00}
Mark Rae [MVP] - 08 Oct 2007 20:07 GMT
> 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")

Signature

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

pvong - 08 Oct 2007 20:18 GMT
Mark,
I'm getting this error message.
Input string was not in a correct format.
I'm trying to do this in VB.Net

>> 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
[quoted text clipped - 3 lines]
>
> AmountL.Text = dr.Item("Amount").ToString("#,##0.00")
Mark Rae [MVP] - 08 Oct 2007 20:27 GMT
[top-posting corrected]

>>> 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
[quoted text clipped - 3 lines]
>>
>> AmountL.Text = dr.Item("Amount").ToString("#,##0.00")

> 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")

Signature

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

pvong - 08 Oct 2007 20:46 GMT
Perfect!  Thanks!

> [top-posting corrected]
>
[quoted text clipped - 11 lines]
>
> AmountL.Text = Convert.ToDecimal(dr.Item("Amount")).ToString("#,##0.00")

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.