By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,948 Members | 1,595 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,948 IT Pros & Developers. It's quick & easy.

Country specific decimal.parse

P: n/a
Following problem:

On a german computer system I am developing a program for international computer systems,

and I want my programm always to run in the same way.

There's a difference in numbers, we use "," instead of "." and "." instead of ",". (Don't know why!!!)

The method decimal.parse tries to handle that, so when you are using it on a german system,

it seems to handle commas as dots and dots as commas, what I don't want it to do.

I am checking for the length of a number, and if it is bigger then 100,000 an error should get thrown.

But 2 digits are allowed. The problem now is, that when someone enters

90,000.39 it sems to cut out the dot, so when I parse it, it gets the number 9,000,039

which is way to big, and an error gets thrown even though it shouldn't.

What can I do to prefend that???

thx,

Stefan

Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Stefan,

You could use ToString methods (Insert, Replace, etc.) to parse it as a string and/or insert the "." and "," manually.

You might use this just as a last resort-or at least after you do all your calculations-because it will be much slower than treating it as a number. Also, this way would bypass your globalization settings, so that might be as preferable.

Eric
"Stefan Richter" <sp**@spammenot.com> wrote in message news:c8***********@otis.netspace.net.au...
Following problem:

On a german computer system I am developing a program for international computer systems,

and I want my programm always to run in the same way.

There's a difference in numbers, we use "," instead of "." and "." instead of ",". (Don't know why!!!)

The method decimal.parse tries to handle that, so when you are using it on a german system,

it seems to handle commas as dots and dots as commas, what I don't want it to do.

I am checking for the length of a number, and if it is bigger then 100,000 an error should get thrown.

But 2 digits are allowed. The problem now is, that when someone enters

90,000.39 it sems to cut out the dot, so when I parse it, it gets the number 9,000,039

which is way to big, and an error gets thrown even though it shouldn't.

What can I do to prefend that???

thx,

Stefan

Nov 20 '05 #2

P: n/a
Hi Stefan,

That comma it is not only Germany, that is all the same in the EU with the exception for the UK, however that country is very slowly accepting the European standards, they have only for a short while the decimal currency and the metric standard.

The currency signs are set by Microsoft accoording the globalization settings, I advise you to keep it that way, because it can give you a lot of trouble when you change that and have no benefits when that will be probably more complete in future.

However with the String formats as "dd - MM - yyyy" for dates, you have when your program is for Europe as far as I know to do nothing (the UK are using that as well) however when you want to use that in the US it is "MM - dd-yyyy"

The same you have to do when you are using string formats with decimal dots and comma's.

However than even for every country in the EU separatly because there is no globalization EU as far as I have seen and the UK has in that the same as the US. (Or let us say the US the same as the UK, which will be probably historical more right.)

I hope this clears this a little bit?

Cor

Nov 20 '05 #3

P: n/a
* "Stefan Richter" <sp**@spammenot.com> scripsit:
[...]

Please post in 'text/plain' format in future.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.