Convert Currency-formatted string back to decimal

Discussion in 'ASP .Net' started by Ritu.Chandra.JBS@gmail.com, May 4, 2006.

  1. Guest

    Hello,

    I am facing a strange problem. My application formats a decimal value
    to a string something like this.

    fprice float;
    sPrice String;

    fprice = 450.77 // This value actually comes from the database
    sPrice = fprice.ToString("C")

    sprice after the above transformation looks like "$450.77"

    Now because of some application requirements after a while I need to
    reformat the string to display "450.77"

    However once this format is applied the system does not recognise
    sPrice as a string anymore and does not let me use any string function
    like 'replace', 'split' etc. It does not even run the GetType method
    without an error (though the system still displays sPrice to be a
    string)

    End result is that I cannot remove this "$" sign from my output.

    Would appreciate some pointers.

    Thanks
    Ritu
    , May 4, 2006
    #1
    1. Advertising

  2. Hi Ritu,

    Just try this
    sPrice = fprice.ToString("N")

    For more formats search for numeric to string conversion formats.

    Thanks
    Kuldeep



    <> wrote in message
    news:...
    > Hello,
    >
    > I am facing a strange problem. My application formats a decimal value
    > to a string something like this.
    >
    > fprice float;
    > sPrice String;
    >
    > fprice = 450.77 // This value actually comes from the database
    > sPrice = fprice.ToString("C")
    >
    > sprice after the above transformation looks like "$450.77"
    >
    > Now because of some application requirements after a while I need to
    > reformat the string to display "450.77"
    >
    > However once this format is applied the system does not recognise
    > sPrice as a string anymore and does not let me use any string function
    > like 'replace', 'split' etc. It does not even run the GetType method
    > without an error (though the system still displays sPrice to be a
    > string)
    >
    > End result is that I cannot remove this "$" sign from my output.
    >
    > Would appreciate some pointers.
    >
    > Thanks
    > Ritu
    >
    Arvind P Rangan, May 4, 2006
    #2
    1. Advertising

  3. Guest

    Arvind P Rangan wrote:
    > Hi Ritu,
    >
    > Just try this
    > sPrice = fprice.ToString("N")
    >
    > For more formats search for numeric to string conversion formats.


    Thanks for the prompt response Kuldeep. Strangely, the solution you
    suggested also does not work. It does not recognise ToString() either.
    I am wondering if this is an application specific error or there is a
    specific way or achieving the above.

    Regards
    Ritu
    , May 4, 2006
    #3
    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,813
    Pabinator
    Aug 28, 2009
  2. Martyn Fewtrell

    String (Currency) to Decimal Conversion

    Martyn Fewtrell, Jun 21, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    4,149
    Martyn Fewtrell
    Jun 21, 2005
  3. =?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:
    893
    Martin Honnen
    Nov 3, 2007
  4. Vitaliy
    Replies:
    1
    Views:
    458
    Peter Otten
    May 29, 2008
  5. jason

    Re-convert Currency back to Integer?

    jason, Sep 1, 2003, in forum: ASP General
    Replies:
    1
    Views:
    161
    jason
    Sep 1, 2003
Loading...

Share This Page