String (Currency) to Decimal Conversion

Discussion in 'ASP .Net' started by Martyn Fewtrell, Jun 21, 2005.

  1. 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

    Martyn Fewtrell, Jun 21, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KB
    Replies:
    3
    Views:
    20,820
    Pabinator
    Aug 28, 2009
  2. Replies:
    2
    Views:
    483
  3. Ven
    Replies:
    3
    Views:
    1,305
  4. =?Utf-8?B?R3JlZyBH?=

    Convert currency formated string back into decimal

    =?Utf-8?B?R3JlZyBH?=, Nov 3, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    896
    Martin Honnen
    Nov 3, 2007
  5. Julia Soare

    Decimal places for currency

    Julia Soare, Feb 12, 2004, in forum: ASP General
    Replies:
    2
    Views:
    106
    Bob Barrows [MVP]
    Feb 12, 2004
Loading...

Share This Page