R
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
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