Format Currency driving me nuts!!!!

  • Thread starter Thread starter rlueneberg
  • Start date Start date
R

rlueneberg

I am having trouble with properly formating decimal numbers.

Look:
decimal NewPrice = 0;
NewPrice = Convert.ToDecimal(Price) * Convert.ToInt32(item.Quantity);

For example, for the decimal value of 1800.00 I get the folowing
results:

without formating
1800.00

with formating
NewPrice.ToString("$#,##0.00")
$1,800.00,800.00

If I change the value to 600, it works?????


Rod
 
Hey Rod,

Not sure where you're going wrong, but try this?

System.Threading.Thread.CurrentThread.CurrentCulture =
new System.Globalization.CultureInfo("en-us");
decimal NewPrice;
double Price= 54.51;
Int32 Quantity=32;
NewPrice = Convert.ToDecimal(Convert.ToDecimal(Price) *
Convert.ToInt32(Quantity));
Label1.Text=NewPrice.ToString("C");

Ken
Microsoft MVP [ASP.NET]
 
Thanks Ken,

I will try it this weekend. Do you knows the difference between the
convert.ToDecimal and the parse.decimal ?

Rod

BTW, here's the reference for the standard numeric format strings:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgu...

Ken
Microsoft MVP [ASP.NET]

I am having trouble with properly formating decimal numbers.
Look:
decimal NewPrice = 0;
NewPrice = Convert.ToDecimal(Price) * Convert.ToInt32(item.Quantity);
For example, for the decimal value of 1800.00 I get the folowing
results:
without formating
1800.00
with formating
NewPrice.ToString("$#,##0.00")
$1,800.00,800.00
If I change the value to 600, it works?????
 
Back
Top