Convert currency formated string back into decimal

Discussion in 'ASP .Net' started by =?Utf-8?B?R3JlZyBH?=, Nov 3, 2007.

  1. A aspx page Label.Text contains formated currency ("0:C"). To process this
    data with the submit button click it needs to be converted to a decimal.

    For example:
    string strCur = "$111.11"; // Label.Text;
    strCur.Remove(0,1);
    decimal dtotal = decimal.Parse(strCur);

    Produces Server Error:
    Exception Details: System.FormatException: Input string not in correct format.

    I can not seem to find the solution with the help index or the forum posts.

    Please help,

    --
    Thank you very much,

    Greg G
    =?Utf-8?B?R3JlZyBH?=, Nov 3, 2007
    #1
    1. Advertising

  2. Greg G wrote:

    > string strCur = "$111.11"; // Label.Text;
    > strCur.Remove(0,1);


    You need
    strCur = strCur.Remove(0,1);
    as strings are immutable so calling Remove on strCur returns a new
    string, it does not change the old one.




    --

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/
    Martin Honnen, Nov 3, 2007
    #2
    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. Chris Baker
    Replies:
    2
    Views:
    22,814
    Roedy Green
    Sep 22, 2003
  3. Replies:
    2
    Views:
    483
  4. =?Utf-8?B?ZGF2aWQ=?=

    Can we populate a XML formated string into a dataset?

    =?Utf-8?B?ZGF2aWQ=?=, Mar 29, 2007, in forum: ASP .Net
    Replies:
    6
    Views:
    438
    =?Utf-8?B?ZGF2aWQ=?=
    Mar 30, 2007
  5. walterbyrd
    Replies:
    13
    Views:
    1,286
    walterbyrd
    May 13, 2009
Loading...

Share This Page