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

Making Convert.ToDecimal() 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.ToDecimal() adapt to the user's language settings? Assume
Windows XP and .NET Framework 1.1.

Gustaf
May 8 '06 #1
2 3924
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.com

"Gustaf" <gu*****@algonet.se> wrote in message
news:ec**************@TK2MSFTNGP03.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.ToDecimal()
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.AllowDecimalPoint and NumberFormatInfo.CurrentInfo, but I
still get the System.FormatException 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
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...
3
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...
12
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...
4
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
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...
1
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: ...
6
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? ...
1
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...
11
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
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
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
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.