String (Currency) to Decimal Conversion

M

Martyn Fewtrell

Hi there

I'm sure there is a straight forward answer to this but I haven't quite got
there.

If I have a String in Sterling Currency Format and try to convert this to a
Decimal (for arithmetic purposes it works fine).

Sample code (VB.Net):

Dim UK As New CultureInfo("en-GB")
SA.Text = (S1.Text * S2.Text).ToString("c", UK)

Dim decSterling as Decimal = SA.Text

(where S1, S2 and SA are text boxes)

If I run the identical code for Dollars this fails with the exception can't
convert String "$...." to Decimal

Sample Code (VB.Net):

Dim US As New CultureInfo("en-US")

DA.Text = (D1.Text * D2.Text).ToString("c", US)

Dim decDollars as Decimal = DA.Text

(where D1, D2 and DA are text boxes)

Why can I convert a string to decimal when using £ (Sterling) but not $
(Dollars)

Thanks for your help

Martyn Fewtrell

(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top