473,804 Members | 3,228 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making Convert.ToDecim al() adapt to the language settings

I read some data from an XML file. Some datas need to be converted to
decimals. The program is to be used in any country, so sometimes the
decimal sign is "." and sometimes ",". How can I make
Convert.ToDecim al() adapt to the user's language settings? Assume
Windows XP and .NET Framework 1.1.

Gustaf
May 8 '06 #1
2 3950
Gustaf,

Instead of using Convert, use the static Parse method on the Decimal
type, the overload which passed in the IFormatProvider .

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Gustaf" <gu*****@algone t.se> wrote in message
news:ec******** ******@TK2MSFTN GP03.phx.gbl...
I read some data from an XML file. Some datas need to be converted to
decimals. The program is to be used in any country, so sometimes the
decimal sign is "." and sometimes ",". How can I make Convert.ToDecim al()
adapt to the user's language settings? Assume Windows XP and .NET Framework
1.1.

Gustaf

May 8 '06 #2
Nicholas Paldino [.NET/C# MVP] wrote:
Instead of using Convert, use the static Parse method on the Decimal
type, the overload which passed in the IFormatProvider .


Thanks, you give me hope this can be solved. But I'll need some further
help on how to specify the IFormatProvider . I tried
NumberStyles.Al lowDecimalPoint and NumberFormatInf o.CurrentInfo, but I
still get the System.FormatEx ception error when I feed Decimal.Parse()
with numbers with the "wrong" decimal character.

Gustaf
May 10 '06 #3

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

Similar topics

2
16226
by: Phil Stanton | last post by:
When designing a new form or report, the Default ForeColor is often something like -2147483640 which is the colour of Windows text (possibly black) and the default backColor is -2147483643 (possibly white) Can anyone tell me how to convert these colours to either RGB colours or the Long number used by Access. Black is 0 and White is 16777215 ...
3
14528
by: Chua Wen Ching | last post by:
I have a problem. But on .NET 1.1 My Scenario: Actually I will have a string of hexadecimals read from a xml file. Then from the hexadecimals, i will add 1 value whenever i made any modifications. But just i do not how to get started. It is like an incremental hexadecimals. I have a string of hex. string strHex = "0100000000FF";
12
2038
by: Wolfgang Kaml | last post by:
Dear all, I am using the following code to retrieve the size of a certain file and the available (free) space on the disk. The problem is, that I get the size of the file returned as a Long and the size of free disk space as UInt64. Apparently, there are no function to convert a Long to a UInt64 or to compare the two (I'm not expecting to convert the UInt64 to a Long necessarily, but it should work the other way round, right?). Short...
4
3815
by: Leon.Kemp | last post by:
In previous versions of VB, changing a string of numerals to a number was easy. Val and convert.todecimal both change 32.75 to 32. What should I be doing here Thank Leo
3
7166
by: mlafarlett | last post by:
In the example below, the 'convert.ToDecimal' removes the trailing 5. I'd like to get the number, in tact, moved to the decimal variable. Any help would be greatly appreciated. Dim dcml As Decimal Dim dbl As Double = 544.4000244140625 dcml = Convert.ToDecimal(dbl) Debug.WriteLine(dcml.ToString)
1
3987
by: =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?= | last post by:
I need to be able to take Wikipedia WikiText markup and convert to HTML. Haven't found anything really useful yet. Anyone? Thanks, Peter -- Site: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com Short urls & more: http://ittyurl.net
6
21807
by: Bob | last post by:
Hello folks. I use this formating but if the value in dr is a null it generates an error "Object cannot be cast from DBNull to other types." Anybody know how I can deal with nulls? Thanks,
1
1846
by: HACKhalo2 | last post by:
Hi. I'm helping a friend of mine develop an online game, which is currently outdated. The person making skins for the site came up with a cool looking NavBar (found at http://www.thejackofclubs.net/images/soc_concept4.png ) and I want to change the current navbar (which is right now generated via PHP using tables and outdated expressions). The code is <script language="javascript" type="text/javascript"> <!-- Modified menu code --> <!-- /*...
11
6264
by: Rafe | last post by:
Hi, I'm working within an application (making a lot of wrappers), but the application is not case sensitive. For example, Typing obj.name, obj.Name, or even object.naMe is all fine (as far as the app is concerned). The problem is, If someone makes a typo, they may get an unexpected error due accidentally calling the original attribute instead of the wrapped version. Does anyone have a simple solution for this?
0
9708
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
9588
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
10589
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...
0
10340
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 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...
1
7625
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
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
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...
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2999
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.