Hi,
Run this code will cause format exception. I think the problem is
induced by using System.Globaliz ation.NumberSty les.Currency since I used
customed currency symbol("My Dollar:").
Please tell me how to modify this block of code.Thanks
Console.WriteLi ne ( NumberValue.ToS tring ( formatString , n ) );
NumberFormatInf o numberFormatInf o = new
System.Globaliz ation.NumberFor matInfo();
numberFormatInf o.CurrencySymbo l = "My Dollar:";
string temp = "My Dollar:234.43";
double ret = double.Parse ( temp ,
System.Globaliz ation.NumberSty les.Currency );
Console.WriteLi ne ( ret ); 2 5691
Hi,
Your problem is that your create the correct NumberFormatInf o 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.Globaliz ation.NumberSty les.Currency,
numberFormatInf o);
Best regards,
Eran Kampf http://www.ekampf.com/ http://www.ekampf.com/blog/
"zlf" <zl***@hotmail. com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. Hi, Run this code will cause format exception. I think the problem is induced by using System.Globaliz ation.NumberSty les.Currency since I used customed currency symbol("My Dollar:"). Please tell me how to modify this block of code.Thanks
Console.WriteLi ne ( NumberValue.ToS tring ( formatString , n ) );
NumberFormatInf o numberFormatInf o = new System.Globaliz ation.NumberFor matInfo(); numberFormatInf o.CurrencySymbo l = "My Dollar:"; string temp = "My Dollar:234.43";
double ret = double.Parse ( temp , System.Globaliz ation.NumberSty les.Currency );
Console.WriteLi ne ( ret );
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 NumberFormatInf o 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.Globaliz ation.NumberSty les.Currency, numberFormatInf o);
Best regards,
Eran Kampf http://www.ekampf.com/ http://www.ekampf.com/blog/
"zlf" <zl***@hotmail. com> wrote in message news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. Hi, Run this code will cause format exception. I think the problem is induced by using System.Globaliz ation.NumberSty les.Currency since I used customed currency symbol("My Dollar:"). Please tell me how to modify this block of code.Thanks
Console.WriteLi ne ( NumberValue.ToS tring ( formatString , n ) );
NumberFormatInf o numberFormatInf o = new System.Globaliz ation.NumberFor matInfo(); numberFormatInf o.CurrencySymbo l = "My Dollar:"; string temp = "My Dollar:234.43";
double ret = double.Parse ( temp , System.Globaliz ation.NumberSty les.Currency );
Console.WriteLi ne ( ret );
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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.
The strange thing in even after storing this when I display the currency on
one page it shoes it as £ but on two of the pages it still shows £
I have looked at the database the value stored is £ where as the user is
|
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 Currency symbol?
|
by: Douglas |
last post by:
Gday,
How would I format a number so that:
TheValue = 32500
Displays in the TextBox as: $32,500.00
|
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.
|
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()
obj.NumberFormat.CurrencySymbol = "Rs"
Session.LCID = obj.LCID
| |
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 '$')
|
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 remove the
formatting characters ($,) ?
I suppose I could always use the replace function to remove the $ and
comma, but I wasn't sure if there was any easier way, i.e. Format(...)
TIA,
Mark
|
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 currency-handling functions inside
them, but I want to display the price on my web site given the information
above, plus the current culture of the web site visitor.
So, I have
|
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 see "$345.45", but if I
have "GBP" and 345.45 I want to see "345.45 ".
I can see how you can start with a culture like en-US and get the output,
but I am starting only from a currency code.
thanks.
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |