473,386 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

IsNumeric() Problem

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
10 2763
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
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
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
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
"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
Michele,

Can you test it like this.

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

Cor
Nov 21 '05 #7
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: eje | last post by:
IsNumeric(value) should return false if value "can not be successfully converted to a Double." Instead I get the following error message: "Input string was not in a correct format." I use the...
4
by: Eugene Anthony | last post by:
I have received the following feedback for the two functions bellow: "The ISNUMERIC test is WORTHLESS for checking for an INT value, because ISNUMERIC will happily accept DOUBLE values, such as...
14
by: Kenny | last post by:
Hello, I would like to know if the function IsNumeric requires a header like #include <iostream> to be functionnal thanks ken
8
by: John Bowman | last post by:
Hello, Does anyone have a good/reliable approach to implementing an IsNumeric() method that accepts a string that may represent a numerical value (eg. such as some text retrieved from an XML...
3
by: Radith Silva | last post by:
Dear All; Thanx for helpt with previous question. Still learning?? FROM A VB 6.0 BOOK: any way; I have used IsNumeric function and check all namespace conflicts and all and nothing seems...
7
by: Nathan Truhan | last post by:
All, I think I may have uncovered a bug in the IsNumeric function, or at least a misunderstanding on functionality. I am writing a Schedule Of Classes Application for our campus and have a...
8
by: moondaddy | last post by:
What's the .net framework equivalent of the vb function isnumeric? If there isn't one, how can I test a string variable to see if its a number or not? I don't want to use isnumeric if possible ...
12
by: sck10 | last post by:
Hello, I am trying to determine if a value is NOT numeric in C#. How do you test for "Not IsNumeric"? protected void fvFunding_ItemInserting_Validate(object sender, FormViewInsertEventArgs...
17
by: MLH | last post by:
I have tested the following in immed window: ?isnumeric(1) True ?isnumeric(1.) True ?isnumeric(1.2) True ?isnumeric(1.2.2)
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.