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

IsNumeric() Problem

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
10 Replies


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

"michele" <mi*****@zenna.it> wrote in message
news:ut**************@TK2MSFTNGP12.phx.gbl...
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

Nov 21 '05 #2

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

"Bernie Yaeger" <be*****@optonline.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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

"michele" <mi*****@zenna.it> wrote in message
news:ut**************@TK2MSFTNGP12.phx.gbl...
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


Nov 21 '05 #3

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

"Curtis" <cs*****@hotmail.com> wrote in message
news:OF*************@tk2msftngp13.phx.gbl...
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

"Bernie Yaeger" <be*****@optonline.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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

"michele" <mi*****@zenna.it> wrote in message
news:ut**************@TK2MSFTNGP12.phx.gbl...
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




Nov 21 '05 #4

P: n/a
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?
"Michael D. Ober" <obermd.@.alum.mit.edu.nospam> ha scritto nel messaggio
news:%2****************@TK2MSFTNGP09.phx.gbl...
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.

"Curtis" <cs*****@hotmail.com> wrote in message
news:OF*************@tk2msftngp13.phx.gbl...
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

"Bernie Yaeger" <be*****@optonline.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
> 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
>
> "michele" <mi*****@zenna.it> wrote in message
> news:ut**************@TK2MSFTNGP12.phx.gbl...
>>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
>>
>
>



Nov 21 '05 #5

P: n/a
"michele" <mi*****@zenna.it> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #6

P: n/a
Michele,

Can you test it like this.

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

Cor
Nov 21 '05 #7

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

"Cor Ligthert [MVP]" <no************@planet.nl> ha scritto nel messaggio
news:%2****************@TK2MSFTNGP14.phx.gbl...
Michele,

Can you test it like this.

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

Cor

Nov 21 '05 #8

P: n/a
ru
On Wed, 21 Sep 2005 16:55:10 +0200, "michele" <mi*****@zenna.it>
wrote:
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/micro...1507af00c0d2b4

ru
Nov 21 '05 #9

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

"ru" <ur@sx3all.be> ha scritto nel messaggio
news:fs********************************@4ax.com...
On Wed, 21 Sep 2005 16:55:10 +0200, "michele" <mi*****@zenna.it>
wrote:
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 onone 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 thecontenet 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/micro...1507af00c0d2b4
ru

Nov 21 '05 #10

P: n/a
ru
On Wed, 28 Sep 2005 11:00:14 +0200, "michele" <mi***********@unipr.it>
wrote:
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

"ru" <ur@sx3all.be> ha scritto nel messaggio
news:fs********************************@4ax.com.. .
On Wed, 21 Sep 2005 16:55:10 +0200, "michele" <mi*****@zenna.it>
wrote:
>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 goodon >one and doesn't run an another one.
>
>The program test is very simple, just a form with a text box and abutton. >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 ifthe >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/micro...1507af00c0d2b4

ru

Nov 21 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.