Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Covert currenct string to decimal data type? 2

Status
Not open for further replies.

codemech

Programmer
Feb 8, 2004
34
0
0
US
How would I convert a currency string to a decimal?

I type "$100.95" in a text box and then want to store it as a decimal.

decimal d = txtPrice.Text;

This throws an exception.


Thanks,
Codemech
 
You may need this to allow for the currency symbol:
Code:
Decimal.Parse(txtPrice.Text, System.Globalization.NumberStyles.Currency)
 
Thanks SHelton! That is a beautiful line of code. I new it was out there but I couldn’t quite craft it.

~~ Codemech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top