本地设置和NumberFormat问题 [英] Local Settings and NumberFormat issues

查看:93
本文介绍了本地设置和NumberFormat问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我从运行我的软件的客户端收到一条错误消息,然后

构建一台具有确切区域设置的测试机作为我的客户

我可以重现这个bug。导致该错误的设置结果为

是设置为,的小数符号。


错误消息为:货币分隔符指定的信息
NumberFormatInfo中的
对于解析是不明确的。


导致错误的代码很简单:

int100 = CInt(txt100.Text)


int100是一个整数

txt100是一个显示整数变量的文本框:没有小数

分隔符涉及,所以我不知道为什么会引发错误。


将代码更改为:

int100 =整数.Parse(txt100History.Text,

NumberStyles.AllowDecimalPoint)

清除错误。


我发现的另一件事是IsNumeric函数也没有
正常工作。以下代码总是返回false,无论

按下了什么键:

Private Sub txtScore_TextChanged(ByVal sender As Object,ByVal e As
System.EventArgs)处理txtScore.TextChanged

如果IsNumeric(txtScore.Text)= False那么

txtScore.Text =""

结束如果

''结束子


有人可以解释为什么抛出错误,尽管没有小数

分离器涉及?而且,用不同的区域设置处理

的最佳方式是什么?


谢谢,

ru



I got an error message from a client running my software, and after
building a test machine with the exact regional settings as my client
I could reproduce the bug. The setting causing the bug turned out to
be the decimal symbol set to ",".

The error message was: "The currency separator information specified
in the NumberFormatInfo is ambiguous for parsing."

The code causing the error was a simple one:
int100 = CInt(txt100.Text)

int100 is an integer
txt100 is a textbox displaying an integer variable: there''s no decimal
separator involved, so I don''t know why this is raising an error.

Changing the code to:
int100 = Integer.Parse(txt100History.Text,
NumberStyles.AllowDecimalPoint)
cleared the error.

Another thing I discovered was that the IsNumeric function also didn''t
work properly. The following code would always return false, no matter
what key was pressed:

Private Sub txtScore_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txtScore.TextChanged
If IsNumeric(txtScore.Text) = False Then
txtScore.Text = ""
End If
''End Sub

Can someone explain why the errors were thrown, eventhough no decimal
separators were involved? And also, what''s the best way in dealing
with different regional settings?

Thanks,
ru


推荐答案

茹,


从你的留言我明白你的意思设置了一些区域设置。


这可能是真的吗?


还有哪些?


Cor
Ru,

From your message I get the idea that you have set some regional settings.

Can that be true?

And than which?

Cor


2005年6月17日星期五16:11:53 +0200,Cor Ligthert

< no *** *********@planet.nl>写道:
On Fri, 17 Jun 2005 16:11:53 +0200, "Cor Ligthert"
<no************@planet.nl> wrote:
Ru,

从你的留言中我知道你已经设置了一些区域设置。

可以是是吗?

而不是?

Cor
Ru,

From your message I get the idea that you have set some regional settings.

Can that be true?

And than which?

Cor




嗨Cor,


就像我在原始邮件中说的那样:

导致错误的设置结果是

是设置为,的小数符号。在区域环境中。


ru



Hi Cor,

like I said in the original message:
The setting causing the bug turned out to
be the decimal symbol set to "," in the regional settings.

ru


Ru,
Ru,
是设置为,的小数符号。在区域设置。
be the decimal symbol set to "," in the regional settings.



这是笑话吗?


Cor


Is this meant as joke?

Cor


这篇关于本地设置和NumberFormat问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆