IsNumeric() Problem

M

michele

I have a problem with VB.Net and IsNumeric() function because it always
returns FALSE even the string can be a number.
There is another strange thing, the same program (it is a test) runs good on
one and doesn't run an another one.

The program test is very simple, just a form with a text box and a button.
The text box has a validation rule that check if the insert string is a
numeric value, that's all.


MsgBox( IsNumeric(TextBox1.Text)) ----<<<< always write FALSE even if the
contenet of TextBox1 is "111"

Thanks in advice, Michele
 
B

Bernie Yaeger

Hi Michele,

I have tested it exactly as you specify, and it returns true when '111' and
false when '1a11'. I don't know what to suggest, other than a reinstall of
the .net framework and vs .net.

Bernie Yaeger
 
C

Curtis

Michele,

I agree with Bernie, I have no problem running that code. You might try
doing a cast of the textbox info. You might try to cast the variable to see
if you get an error from that:

dblVar = CDbl(txtInput.Text)

Curtis
 
M

Michael D. Ober

Try MsgBox(IsNumeric(Trim$(TextBox1.Text))).

Because Windows Forms used proportional fonts, you might have spaces at the
beginning of the text box value. Leading spaces can cause IsNumeric to
misread a value. Also, make sure you have "111" vs. "lll" (lower case LLL).

Mike Ober.
 
M

michele

I developed a little program that works and then an another user asked me if
I can install the same program on his computer. Either computer has Windows
XP Pro and I installed the framework.
I develop a little program just for test the IsNumeric() function: a form, a
textbox and button.
I can't understand why the framework doen't work.
There are tool to check the framework?
 
H

Herfried K. Wagner [MVP]

michele said:
I developed a little program that works and then an another user asked me
if I can install the same program on his computer. Either computer has
Windows XP Pro and I installed the framework.
I develop a little program just for test the IsNumeric() function: a form,
a textbox and button.
I can't understand why the framework doen't work.
There are tool to check the framework?

Which language does the operating system have? Which version of the .NET
Framework is installed? You can use the batch file provided by Frank
Dzaebel (<URL:http://www.dzaebel.net/NetVersions.htm>) to determine the
installed versions of the .NET Framework.
 
C

Cor Ligthert [MVP]

Michele,

Can you test it like this.

\\\
TextBox1.Text = "111"
MsgBox(IsNumeric(TextBox1.Text))
///
I hope this helps,

Cor
 
M

michele

I did it in my trouble shooting but the problem is in the machine where is
installed Visual Studio works well and also in other pc but when I try to
run it on that pc It returns FALSE so I think there is some problem with the
framework but I don't know which ones.
Thanks
 
R

ru

I have a problem with VB.Net and IsNumeric() function because it always
returns FALSE even the string can be a number.
There is another strange thing, the same program (it is a test) runs good on
one and doesn't run an another one.

The program test is very simple, just a form with a text box and a button.
The text box has a validation rule that check if the insert string is a
numeric value, that's all.


MsgBox( IsNumeric(TextBox1.Text)) ----<<<< always write FALSE even if the
contenet of TextBox1 is "111"

Thanks in advice, Michele

I had the same thing a couple of months ago, and it turned out to be a
Regional Settings thing: a decimal separator and a thousands separator
set to the same symbol. Fiddle around with it to see when and what
causes the error.

I changed the IsNumeric() logic to the following routine, and that
helped:

Private Sub txtScore_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtScore.KeyPress
If e.KeyChar < "0" Or e.KeyChar > "9" Then
If (e.KeyChar = Chr(&H8)) Or (e.KeyChar = "Keys.Delete")
Then
Else
e.Handled = True
End If
End If
End Sub

Here's the related thread:
http://groups.google.com/group/micr...roup:*.dotnet.*&rnum=1&hl=en#e51507af00c0d2b4

ru
 
M

michele

I changed the regional setting and then the function IsNumeric() has started
but I can't adopt this kind of solution because another program doesn' t
work if the decimal separator is different from comma character. I think the
solution is if I can change character separator on run-time
 
R

ru

I changed the regional setting and then the function IsNumeric() has started
but I can't adopt this kind of solution because another program doesn' t
work if the decimal separator is different from comma character. I think the
solution is if I can change character separator on run-time


Or forget the IsNumeric() function altogether, and write your own
logic.
Good luck.

ru
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top