Convert Currency-formatted string back to decimal

  • Thread starter Ritu.Chandra.JBS
  • Start date
R

Ritu.Chandra.JBS

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
 
A

Arvind P Rangan

Hi Ritu,

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

For more formats search for numeric to string conversion formats.

Thanks
Kuldeep
 
R

Ritu.Chandra.JBS

Arvind said:
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
 

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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top