Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Convert currency formated string back into decimal

Thread Tools

Convert currency formated string back into decimal

Posts: n/a
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;
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
Reply With Quote
Martin Honnen
Posts: n/a
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
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Currency-formatted string back to decimal KB ASP .Net 3 08-28-2009 02:25 AM
Convert UNIX formated text files to DOS formated? walterbyrd Python 13 05-13-2009 02:32 PM
Convert Currency-formatted string back to decimal ASP .Net 2 05-04-2006 01:14 PM
String (Currency) to Decimal Conversion Martyn Fewtrell ASP .Net 0 06-21-2005 03:59 PM
How to convert a double into a currency string Chris Baker Java 2 09-22-2003 01:15 AM