473,387 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to translate number with customed currency symbol to number

zlf
Hi,
Run this code will cause format exception. I think the problem is
induced by using System.Globalization.NumberStyles.Currency since I used
customed currency symbol("My Dollar:").
Please tell me how to modify this block of code.Thanks

Console.WriteLine ( NumberValue.ToString ( formatString , n ) );

NumberFormatInfo numberFormatInfo = new
System.Globalization.NumberFormatInfo();
numberFormatInfo.CurrencySymbol = "My Dollar:";
string temp = "My Dollar:234.43";

double ret = double.Parse ( temp ,
System.Globalization.NumberStyles.Currency );

Console.WriteLine ( ret );
Nov 16 '05 #1
2 5651
Hi,
Your problem is that your create the correct NumberFormatInfo but you do not
pass it to the double.Parse so the parsing function uses the system's
default currency format...
Modify the double.Parse call to the following:
double ret = double.Parse (temp, System.Globalization.NumberStyles.Currency,
numberFormatInfo);

Best regards,

Eran Kampf
http://www.ekampf.com/
http://www.ekampf.com/blog/
"zlf" <zl***@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,
Run this code will cause format exception. I think the problem is
induced by using System.Globalization.NumberStyles.Currency since I used
customed currency symbol("My Dollar:").
Please tell me how to modify this block of code.Thanks

Console.WriteLine ( NumberValue.ToString ( formatString , n ) );

NumberFormatInfo numberFormatInfo = new
System.Globalization.NumberFormatInfo();
numberFormatInfo.CurrencySymbol = "My Dollar:";
string temp = "My Dollar:234.43";

double ret = double.Parse ( temp ,
System.Globalization.NumberStyles.Currency );

Console.WriteLine ( ret );

Nov 16 '05 #2
zlf
Hi,
I modify my code with your suggestion and it runs correctly.Thank you
very much.

zlf

"Eran Kampf" <er********@sap.com> дÈëÏûÏ¢ÐÂÎÅ:d1**********@news.sap-ag.de...
Hi,
Your problem is that your create the correct NumberFormatInfo but you do
not
pass it to the double.Parse so the parsing function uses the system's
default currency format...
Modify the double.Parse call to the following:
double ret = double.Parse (temp,
System.Globalization.NumberStyles.Currency,
numberFormatInfo);

Best regards,

Eran Kampf
http://www.ekampf.com/
http://www.ekampf.com/blog/
"zlf" <zl***@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,
Run this code will cause format exception. I think the problem is
induced by using System.Globalization.NumberStyles.Currency since I used
customed currency symbol("My Dollar:").
Please tell me how to modify this block of code.Thanks

Console.WriteLine ( NumberValue.ToString ( formatString , n ) );

NumberFormatInfo numberFormatInfo = new
System.Globalization.NumberFormatInfo();
numberFormatInfo.CurrencySymbol = "My Dollar:";
string temp = "My Dollar:234.43";

double ret = double.Parse ( temp ,
System.Globalization.NumberStyles.Currency );

Console.WriteLine ( ret );


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: J P Singh | last post by:
Hi Guys I am trying to store the currency symbol used for a trasaction in a database field but rather than store £ it stores £ (see the wierd character at the beginning of the symbol) instead....
3
by: John H. | last post by:
Hi, Why if set a DataTable in Crystal Report Net Table with method SetDataSource, 'ReportDocument.SetDataSource(oDataTable)', lost the Number and Currency format with the decimal digits and...
16
by: Douglas | last post by:
Gday, How would I format a number so that: TheValue = 32500 Displays in the TextBox as: $32,500.00
13
by: jm | last post by:
I am trying to use datepart to get the real name of the month like "April" or "APR" not just "4." I could not find it in the documentation. Sorry. Thank you.
1
by: Sakharam Phapale | last post by:
Hi All, I want to change currency symbol of current culture. I am trying to do this by following code. Dim obj As CultureInfo = System.Globalization.CultureInfo.CurrentCulture()...
7
by: zlf | last post by:
1¡¢Here is a number. double nu = 123 2¡¢Format it with 3¡¢The result is "$123" I want to ask how to deformat "$123" to 123 Thx (Currency symbol is not restricted to '$')
5
by: Mark | last post by:
I have a field that has been formatted using the vb.net FormatCurrency method. Now, I need to get the amount back into a regular field so I can use it for calculations. Is there an easy way to...
18
by: Boris Yeltsin | last post by:
OK, I have a database table, it has prices of products in it, like so: ProductPrice MONEY ProductIsoCurrencyCode CHAR(3) Now, both CultureInfo and RegionInfo have...
3
by: pb | last post by:
If I have a currency code like "USD" or "EUR", how do I format a string from a decimal value that would contain the correct currency symbol? for example, if I have "USD" and 345.45, I want to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.