473,396 Members | 2,029 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,396 software developers and data experts.

How to translate number with currency format to pure number

zlf
1¡¢Here is a number. double nu = 123
2¡¢Format it with [NumberFormatInfo]
3¡¢The result is "$123"

I want to ask how to deformat "$123" to 123
Thx
(Currency symbol is not restricted to '$')
Nov 16 '05 #1
7 4514
hi zlf,

I have done something like this. Hope this helps!

// Gets a NumberFormatInfo associated with the en-US culture.
NumberFormatInfo nfi = new CultureInfo( "en-US", false ).NumberFormat;

double myInt = 123;
nfi.CurrencySymbol = "$";

//This will show the number formatted with $
Console.WriteLine(myInt.ToString( "C", nfi ));

//This will convert back the curreny amout without the $ symbol
Console.WriteLine(myInt.ToString( "N", nfi ));

Note: I have used Winform to test this code.

happy programming

pradeep_TP

"zlf" wrote:
1¡¢Here is a number. double nu = 123
2¡¢Format it with [NumberFormatInfo]
3¡¢The result is "$123"

I want to ask how to deformat "$123" to 123
Thx
(Currency symbol is not restricted to '$')

Nov 16 '05 #2
Decimal.Parse("$123.00",System.Globalization.Numbe rStyles.Currency)

Dale Preston
MCAD,MCDBA, MCSE
"zlf" <zl***@hotmail.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
1¡¢Here is a number. double nu = 123
2¡¢Format it with [NumberFormatInfo]
3¡¢The result is "$123"

I want to ask how to deformat "$123" to 123
Thx
(Currency symbol is not restricted to '$')

Nov 16 '05 #3
Decimal.Parse("$123.00",System.Globalization.Numbe rStyles.Currency)

Dale Preston
MCAD,MCDBA, MCSE

"zlf" <zl***@hotmail.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
1¡¢Here is a number. double nu = 123
2¡¢Format it with [NumberFormatInfo]
3¡¢The result is "$123"

I want to ask how to deformat "$123" to 123
Thx
(Currency symbol is not restricted to '$')

Nov 16 '05 #4
zlf
Thank you^_^
"pradeep_TP" <pr*******@discussions.microsoft.com> дÈëÏûÏ¢ÐÂÎÅ:71**********************************@ microsoft.com...
hi zlf,

I have done something like this. Hope this helps!

// Gets a NumberFormatInfo associated with the en-US culture.
NumberFormatInfo nfi = new CultureInfo( "en-US", false ).NumberFormat;

double myInt = 123;
nfi.CurrencySymbol = "$";

//This will show the number formatted with $
Console.WriteLine(myInt.ToString( "C", nfi ));

//This will convert back the curreny amout without the $ symbol
Console.WriteLine(myInt.ToString( "N", nfi ));

Note: I have used Winform to test this code.

happy programming

pradeep_TP

"zlf" wrote:
1?¡éHere is a number. double nu = 123
2?¡éFormat it with [NumberFormatInfo]
3?¡éThe result is "$123"

I want to ask how to deformat "$123" to 123
Thx
(Currency symbol is not restricted to '$')

Nov 16 '05 #5
zlf
Thank you for your help.
But I executed the code just now and system will throw
System.FormatException in run-time. May you give me the code that can run
correctly. Thx
"Dale Preston" <da******@nospam.nospam> дÈëÏûÏ¢ÐÂÎÅ:uv**************@tk2msftngp13.phx.gbl ...
Decimal.Parse("$123.00",System.Globalization.Numbe rStyles.Currency)

Dale Preston
MCAD,MCDBA, MCSE

"zlf" <zl***@hotmail.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
1¡¢Here is a number. double nu = 123
2¡¢Format it with [NumberFormatInfo]
3¡¢The result is "$123"

I want to ask how to deformat "$123" to 123
Thx
(Currency symbol is not restricted to '$')


Nov 16 '05 #6
Console.WriteLine(Decimal.Parse("$123.00",System.G lobalization.NumberStyles.
Currency));

If you need a string, you just make it:

Console.WriteLine(Decimal.Parse("$123.00",System.G lobalization.NumberStyles.
Currency).ToString());

Dale Preston

"zlf" <zl***@hotmail.com> wrote in message
news:#W*************@TK2MSFTNGP14.phx.gbl...
Thank you for your help.
But I executed the code just now and system will throw
System.FormatException in run-time. May you give me the code that can run
correctly. Thx
"Dale Preston" <da******@nospam.nospam>

дÈëÏûÏ¢ÐÂÎÅ:uv**************@tk2msftngp13.phx.gbl ...
Decimal.Parse("$123.00",System.Globalization.Numbe rStyles.Currency)

Dale Preston
MCAD,MCDBA, MCSE

"zlf" <zl***@hotmail.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
1¡¢Here is a number. double nu = 123
2¡¢Format it with [NumberFormatInfo]
3¡¢The result is "$123"

I want to ask how to deformat "$123" to 123
Thx
(Currency symbol is not restricted to '$')



Nov 16 '05 #7
zlf
Hi,Dale Preston
I know why system will throw exception when executing the code. The
reason is my location is out of US,but setting the currency to dollar. After
changing my location and currency format to US, the problem disappered.
Thank you very much:)
zlf
"Dale Preston" <da******@nospam.nospam> дÈëÏûÏ¢ÐÂÎÅ:eg**************@TK2MSFTNGP09.phx.gbl ...
Console.WriteLine(Decimal.Parse("$123.00",System.G lobalization.NumberStyles.
Currency));

If you need a string, you just make it:

Console.WriteLine(Decimal.Parse("$123.00",System.G lobalization.NumberStyles.
Currency).ToString());

Dale Preston

"zlf" <zl***@hotmail.com> wrote in message
news:#W*************@TK2MSFTNGP14.phx.gbl...
Thank you for your help.
But I executed the code just now and system will throw
System.FormatException in run-time. May you give me the code that can run
correctly. Thx
"Dale Preston" <da******@nospam.nospam>

дÈëÏûÏ¢ÐÂÎÅ:uv**************@tk2msftngp13.phx.gbl ...
> Decimal.Parse("$123.00",System.Globalization.Numbe rStyles.Currency)
>
> Dale Preston
> MCAD,MCDBA, MCSE
>
> "zlf" <zl***@hotmail.com> wrote in message
> news:en**************@TK2MSFTNGP09.phx.gbl...
>> 1¡¢Here is a number. double nu = 123
>> 2¡¢Format it with [NumberFormatInfo]
>> 3¡¢The result is "$123"
>>
>> I want to ask how to deformat "$123" to 123
>> Thx
>> (Currency symbol is not restricted to '$')
>>
>>
>
>



Nov 16 '05 #8

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

Similar topics

2
by: Dalan | last post by:
This should not be an issue, but it is. I'm sure that someone knows what little piece of code is needed too persuade Access 97 to include a currency format for labels (Avery, mailing type). Have...
2
by: DD | last post by:
I have a UnionQry that is run from StatementsI and StatementP. the Due and Paid colunms are currency and show the $ however when i union the two the currency format has gone. Any help please...
2
by: Bob Dydd | last post by:
Hi Everbody Question Changing the regional settings ie. from UK to US AUS etc, Access retains the original currency format that the application was created in. So if an mdb that is written...
3
by: Scott Gorman | last post by:
I have created a report in access. I had to add a text box to input a value for previous months balance. I have formatted to display with $ currency, and also with the " , " for thousand separator....
3
by: Claudia Fong | last post by:
Hi, My db is stored in access and I have a field amount and its type is currency. When I read from the db and display it in a textbox, it shows me 15000000 instead of $150,000.00. How can...
2
by: zlf | last post by:
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...
4
by: Richard Kessler | last post by:
I am relatively new to Python. Love it, but I find things that I can do easily in .NET and cannot find a way to do in Python. I need to format a number as currency, for example 12343.56 to...
0
by: santoshsri | last post by:
Hello, I have written a Console application in C#, it basically imports data from tab delimited text files and save in SQl Server database. I am converting currency format of Mortgage value into...
2
by: Ian | last post by:
I have an Access 2000 database written in the UK, this database has many fields set to Currency, I now want to move this database over to a user in the USA but my Currency fields still show the UK...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.