Malfist
Malfist

Reputation: 31815

Bound Textbox to a currency, how to get the double?

I have a textbox bound to a currency data field. So it adds '$' to the start of the text or ($xx.xx) if it's negative. How do I get just the plain double (xx.xx) from the textbox instead of everything ($xx.xx)?

Upvotes: 0

Views: 732

Answers (1)

David Morton
David Morton

Reputation: 16505

Make sure you set the proper NumberStyles flags when calling double.Parse.

Obviously, you'd use the example below but replace the literal string with a reference to the text in the TextBox.

double d = double.Parse ("$10.10", NumberStyles.Currency);

Upvotes: 1

Related Questions