Decimal point and different locales

  • Thread starter Thread starter Dave Griffiths
  • Start date Start date
D

Dave Griffiths

Hi All

Using VB 2005

I am writing a program that will be used on machines which have
different locales (English, Norwegian and Swedish)

I am restricting textbox input using keypress to just numbers, control
chars and the decimal point, my problem is that the decimal point on
English machines is the . (dot) unless specifically changed and on
Scandinavian machines is the , (commer). I could just allow both
through the routine but this then gives an added problem that
scandinavia uses the . (dot) as the thousands seperator which would
really cause some confussion.

How do I check for the decimal point set in the machines locale
setup..?

Thanks in advance.
 
Dave Griffiths said:
Hi All

Using VB 2005

I am writing a program that will be used on machines which have
different locales (English, Norwegian and Swedish)

I am restricting textbox input using keypress to just numbers,
control chars and the decimal point, my problem is that the decimal
point on English machines is the . (dot) unless specifically changed
and on Scandinavian machines is the , (commer). I could just allow
both through the routine but this then gives an added problem that
scandinavia uses the . (dot) as the thousands seperator which would
really cause some confussion.

How do I check for the decimal point set in the machines locale
setup..?

Thanks in advance.


See members of

System.Globalization.CultureInfo.CurrentCulture.NumberFormat


Though, I suggest not to limit user input /while typing/. It's a pain,
often. In addition, pasting via clipboard would have to be handled, too.
Instead, use the TryParse-methods (e.g. decimal.tryparse) and give a visual
feedback, like a different text color for invalid input. Give a hint (msgbox
etc) to the user not before leaving the field or when you really need to
process the input. Just a suggestion.


Armin
 
Thanks Armin for the reply so quickly.

I like the suggestion of tryparse will make the program a little more
user friendly.

Thanks again fot your suggestions.
 
through the routine but this then gives an added problem that
scandinavia uses the . (dot) as the thousands seperator which would
really cause some confussion.

I don't know about Norway, but in Sweden we use a space, not a dot as
thousand separator, for common numbers, that is.

For currency, however, we do use a dot as thousand separator.

Not only do we have a tricky language, with words virtually impossible
for foreigners to pronouce, we've got tricky computer settings as
well... ;-)
 
Back
Top