473,725 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to translate number with currency format to pure number

zlf
1¡¢Here is a number. double nu = 123
2¡¢Format it with [NumberFormatInf o]
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 4537
hi zlf,

I have done something like this. Hope this helps!

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

double myInt = 123;
nfi.CurrencySym bol = "$";

//This will show the number formatted with $
Console.WriteLi ne(myInt.ToStri ng( "C", nfi ));

//This will convert back the curreny amout without the $ symbol
Console.WriteLi ne(myInt.ToStri ng( "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 [NumberFormatInf o]
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. NumberStyles.Cu rrency)

Dale Preston
MCAD,MCDBA, MCSE
"zlf" <zl***@hotmail. com> wrote in message
news:en******** ******@TK2MSFTN GP09.phx.gbl...
1¡¢Here is a number. double nu = 123
2¡¢Format it with [NumberFormatInf o]
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. NumberStyles.Cu rrency)

Dale Preston
MCAD,MCDBA, MCSE

"zlf" <zl***@hotmail. com> wrote in message
news:en******** ******@TK2MSFTN GP09.phx.gbl...
1¡¢Here is a number. double nu = 123
2¡¢Format it with [NumberFormatInf o]
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*******@disc ussions.microso ft.com> дÈëÏûÏ¢ÐÂÎÅ:71 *************** *************** ****@microsoft. com...
hi zlf,

I have done something like this. Hope this helps!

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

double myInt = 123;
nfi.CurrencySym bol = "$";

//This will show the number formatted with $
Console.WriteLi ne(myInt.ToStri ng( "C", nfi ));

//This will convert back the curreny amout without the $ symbol
Console.WriteLi ne(myInt.ToStri ng( "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 [NumberFormatInf o]
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.FormatEx ception in run-time. May you give me the code that can run
correctly. Thx
"Dale Preston" <da******@nospa m.nospam> дÈëÏûÏ¢ÐÂÎÅ:uv **************@ tk2msftngp13.ph x.gbl...
Decimal.Parse(" $123.00",System .Globalization. NumberStyles.Cu rrency)

Dale Preston
MCAD,MCDBA, MCSE

"zlf" <zl***@hotmail. com> wrote in message
news:en******** ******@TK2MSFTN GP09.phx.gbl...
1¡¢Here is a number. double nu = 123
2¡¢Format it with [NumberFormatInf o]
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.WriteLi ne(Decimal.Pars e("$123.00",Sys tem.Globalizati on.NumberStyles .
Currency));

If you need a string, you just make it:

Console.WriteLi ne(Decimal.Pars e("$123.00",Sys tem.Globalizati on.NumberStyles .
Currency).ToStr ing());

Dale Preston

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

дÈëÏûÏ¢ÐÂÎÅ:uv **************@ tk2msftngp13.ph x.gbl...
Decimal.Parse(" $123.00",System .Globalization. NumberStyles.Cu rrency)

Dale Preston
MCAD,MCDBA, MCSE

"zlf" <zl***@hotmail. com> wrote in message
news:en******** ******@TK2MSFTN GP09.phx.gbl...
1¡¢Here is a number. double nu = 123
2¡¢Format it with [NumberFormatInf o]
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******@nospa m.nospam> дÈëÏûÏ¢ÐÂÎÅ:eg **************@ TK2MSFTNGP09.ph x.gbl...
Console.WriteLi ne(Decimal.Pars e("$123.00",Sys tem.Globalizati on.NumberStyles .
Currency));

If you need a string, you just make it:

Console.WriteLi ne(Decimal.Pars e("$123.00",Sys tem.Globalizati on.NumberStyles .
Currency).ToStr ing());

Dale Preston

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

дÈëÏûÏ¢ÐÂÎÅ:uv **************@ tk2msftngp13.ph x.gbl...
> Decimal.Parse(" $123.00",System .Globalization. NumberStyles.Cu rrency)
>
> Dale Preston
> MCAD,MCDBA, MCSE
>
> "zlf" <zl***@hotmail. com> wrote in message
> news:en******** ******@TK2MSFTN GP09.phx.gbl...
>> 1¡¢Here is a number. double nu = 123
>> 2¡¢Format it with [NumberFormatInf o]
>> 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
9608
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 had no problems with currency formatting on reports - just the labels. Doesn't matter if the associated field in the Table and Form have Format as Currency, because on the labels (for instance $50.00) prints as: 50 The only way to get it to print...
2
2234
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 SELECT * FROM qryStatementI UNION SELECT * FROM qryStatementP ORDER BY thedate;
2
4557
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 on a computer with Regional Settings Currency Format set to UK £'s , when that mdb is open on a machine
3
31981
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. I have not been able to get it to display correctly. It is just the numbers without the formatting. Please help !!! *** Sent via Developersdex http://www.developersdex.com ***
3
6149
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 I do so it can shows me currency format?
2
5689
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 me how to modify this block of code.Thanks Console.WriteLine ( NumberValue.ToString ( formatString , n ) ); NumberFormatInfo numberFormatInfo = new System.Globalization.NumberFormatInfo();
4
6065
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 $12,343.56. In C# all I need to do is decimal x = 12343.56 then x.ToString("$###,###.00"); I cannot find a way to do this in Python. I must be missing something very simple here. I have tried the locale module but it will not put in the commas. I...
0
1538
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 Number format and saving in database. All works fine at my local machine but when I deployed the .Exe file in test environment I am getting below error message ... Couldn't store <"$182,458.00"> in MortgageValue Column. Can any one help me out...
2
3880
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 £ sign. If I look at these currency fields on my UK PC with it set to regional UK (not USA) then the fields format settings just say Currency, if I then add the USA region to my PC and look at the format again it says: £#,##0.00;-£#,##0.00 I...
0
8888
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6702
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4517
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4782
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2634
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.