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

Decimal point and different locales

P: n/a
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
Aug 3 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Dave Griffiths" <da*********@nospam.hotmail.comschrieb
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.Nu mberFormat
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

Aug 3 '07 #2

P: n/a
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.

--
Dave Griffiths
Armin Zingler wrote:
"Dave Griffiths" <da*********@nospam.hotmail.comschrieb
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.Nu mberFormat
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
Aug 3 '07 #3

P: n/a
When i encountered a simular problem i noticed that the windows calculator
and programs from MS ( excel for instance ) behaved exactly how i wanted it

see this thread with some nice solutions and in the end the simple solution
that replicated exactly the behavior of calc.exe and excel

http://groups.google.nl/group/micros...4f59279602071c

"Dave Griffiths" <da*********@nospam.hotmail.comschreef in bericht
news:BP*********************@telenor.com...
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.

--
Dave Griffiths
Armin Zingler wrote:
>"Dave Griffiths" <da*********@nospam.hotmail.comschrieb
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.Nu mberFormat
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

Aug 3 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.