Country specific decimal.parse

  • Thread starter Thread starter Stefan Richter
  • Start date Start date
S

Stefan Richter

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
 
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
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
 
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
 
Back
Top