Nov 29, 2005 #1 codemech Programmer Feb 8, 2004 34 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
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
Nov 29, 2005 #2 JurkMonkey Programmer Nov 23, 2004 1,731 CA Try this: Convert.ToDouble(txtPrice.Text); Upvote 0 Downvote
Nov 30, 2005 2 #3 SHelton Programmer Jun 10, 2003 541 GB You may need this to allow for the currency symbol: Code: Decimal.Parse(txtPrice.Text, System.Globalization.NumberStyles.Currency) Upvote 0 Downvote
You may need this to allow for the currency symbol: Code: Decimal.Parse(txtPrice.Text, System.Globalization.NumberStyles.Currency)
Nov 30, 2005 Thread starter #4 codemech Programmer Feb 8, 2004 34 US Thanks SHelton! That is a beautiful line of code. I new it was out there but I couldn’t quite craft it. ~~ Codemech Upvote 0 Downvote
Thanks SHelton! That is a beautiful line of code. I new it was out there but I couldn’t quite craft it. ~~ Codemech