I have tested the following in immed window:
?isnumeric(1)
True
?isnumeric(1.)
True
?isnumeric(1.2)
True
?isnumeric(1.2. 2)
The last one does not print True nor False.
Instead, A97 complains of a compile error.
I would really prefer False, should such be
the case. What's the best way not to be
bothered with the error and just assume
False is returned?
Experimenting with CStr was not fruitful
because 1.2.2 is neither a valid numeric
expression nor a valid string expression.
So, what can I do if I find myself needing
to process ?CStr(1.2.2) in the same way
?CStr("1.2.2") would be processed.
If a user enters 1.2.2 in an unbound text-
box expecting a valid numeric entry, I
would like very much to determine, in
code, that it is NOT a valid numeric.
But IsNumeric(1.2.2 ) is not the answer
and neither is IsNumeric(CStr( 1.2.2)). So
what do I do? 17 2273
MLH wrote:
I have tested the following in immed window:
?isnumeric(1)
True
?isnumeric(1.)
True
?isnumeric(1.2)
True
?isnumeric(1.2. 2)
The last one does not print True nor False.
Instead, A97 complains of a compile error.
I would really prefer False, should such be
the case. What's the best way not to be
bothered with the error and just assume
False is returned?
Experimenting with CStr was not fruitful
because 1.2.2 is neither a valid numeric
expression nor a valid string expression.
Why is it not a valid string?
So, what can I do if I find myself needing
to process ?CStr(1.2.2) in the same way
?CStr("1.2.2") would be processed.
Put quotes around it. You're in debug, not a form or report or query or
table.
If a user enters 1.2.2 in an unbound text-
box expecting a valid numeric entry, I
would like very much to determine, in
code, that it is NOT a valid numeric.
But IsNumeric(1.2.2 ) is not the answer
and neither is IsNumeric(CStr( 1.2.2)). So
what do I do?
I created a form. I added a textbox. In the AfterUpdate event I have
the following code.
Private Sub Text2_AfterUpda te()
If IsNumeric(Me.Te xt2) Then
MsgBox "Numeric"
Else
MsgBox "Alpha"
End If
End Sub
I entered 1.2.2 and I got "Alpha". Which is correct.
There's a difference between using a form and entering data into an
immedicate window.
On Sun, 27 Jul 2008 19:50:17 -0700, Salad <oi*@vinegar.co mwrote:
Hi Salad,
I don't agree with your assertion "There's a difference between using
a form and entering data into an immedicate window" at least when it
comes to the performance of IsNumeric. Both environments use the same
VBA to do their job.
The reason isnumeric(1.2.2 ) fails whereas the other ones MLH mentions
succeed is that this one does not convert to a number or a string.
The help file says that IsNumeric takes a number or a string. 1.2.2 is
neither. That's why it fails.
-Tom.
Microsoft Access MVP
>MLH wrote:
>I have tested the following in immed window:
?isnumeric(1 ) True ?isnumeric(1 .) True ?isnumeric(1.2 ) True ?isnumeric(1.2 .2)
The last one does not print True nor False. Instead, A97 complains of a compile error. I would really prefer False, should such be the case. What's the best way not to be bothered with the error and just assume False is returned?
Experimentin g with CStr was not fruitful because 1.2.2 is neither a valid numeric expression nor a valid string expression.
Why is it not a valid string?
>So, what can I do if I find myself needing to process ?CStr(1.2.2) in the same way ?CStr("1.2.2 ") would be processed.
Put quotes around it. You're in debug, not a form or report or query or table.
>If a user enters 1.2.2 in an unbound text- box expecting a valid numeric entry, I would like very much to determine, in code, that it is NOT a valid numeric. But IsNumeric(1.2.2 ) is not the answer and neither is IsNumeric(CStr( 1.2.2)). So what do I do?
I created a form. I added a textbox. In the AfterUpdate event I have the following code. Private Sub Text2_AfterUpda te()
If IsNumeric(Me.Te xt2) Then
MsgBox "Numeric"
Else
MsgBox "Alpha"
End If End Sub
I entered 1.2.2 and I got "Alpha". Which is correct.
There's a difference between using a form and entering data into an immedicate window.
Tom van Stiphout wrote:
On Sun, 27 Jul 2008 19:50:17 -0700, Salad <oi*@vinegar.co mwrote:
Hi Salad,
I don't agree with your assertion "There's a difference between using
a form and entering data into an immedicate window" at least when it
comes to the performance of IsNumeric. Both environments use the same
VBA to do their job.
I can enter 1.1.1 into a text box with no quotes and IsNumeric works
just find.
If I am in Debug, to enter 1.1.1 not in quotes is incorrect. Is isn't a
number, it's a string. It's the same as if I wrote
? Isnumeric(Hi Tom!)
I'd expect an error.
I doubt MLH would have gotten an error if he did this
var = "1.1.1"
? Isnumeric(var)
The reason I would get an accurate result using an unbound textbox in a
form is that Text0, in my opionion, is similar to a variable of type
variant.
>
The reason isnumeric(1.2.2 ) fails whereas the other ones MLH mentions
succeed is that this one does not convert to a number or a string.
The help file says that IsNumeric takes a number or a string. 1.2.2 is
neither. That's why it fails.
The only time I can see MLH's error occurring is if he's doing
everything from the debug/immediate window. To me, that is a data
entry, perhaps logic, error he made in the Debug window. IOW...user error.
The advice he was seeking, as far as I'm concerned, is how does he/she
write statements in the Debug window and what to do if the statement is
incorrect.
>
-Tom.
Microsoft Access MVP
>>MLH wrote:
>>>I have tested the following in immed window:
?isnumeric(1 ) True ?isnumeric(1 .) True ?isnumeric(1 .2) True ?isnumeric(1 .2.2)
The last one does not print True nor False. Instead, A97 complains of a compile error. I would really prefer False, should such be the case. What's the best way not to be bothered with the error and just assume False is returned?
Experimentin g with CStr was not fruitful because 1.2.2 is neither a valid numeric expression nor a valid string expression.
Why is it not a valid string?
>>>So, what can I do if I find myself needing to process ?CStr(1.2.2) in the same way ?CStr("1.2.2 ") would be processed.
Put quotes around it. You're in debug, not a form or report or query or table.
>>>If a user enters 1.2.2 in an unbound text- box expecting a valid numeric entry, I would like very much to determine, in code, that it is NOT a valid numeric. But IsNumeric(1.2.2 ) is not the answer and neither is IsNumeric(CStr( 1.2.2)). So what do I do?
I created a form. I added a textbox. In the AfterUpdate event I have the following code. Private Sub Text2_AfterUpda te() If IsNumeric(Me.Te xt2) Then MsgBox "Numeric" Else MsgBox "Alpha" End If End Sub
I entered 1.2.2 and I got "Alpha". Which is correct.
There's a difference between using a form and entering data into an immedicate window.
On Sun, 27 Jul 2008 21:31:35 -0700, Salad <oi*@vinegar.co mwrote:
>Tom van Stiphout wrote:
>On Sun, 27 Jul 2008 19:50:17 -0700, Salad <oi*@vinegar.co mwrote:
Hi Salad, I don't agree with your assertion "There's a difference between using a form and entering data into an immedicate window" at least when it comes to the performance of IsNumeric. Both environments use the same VBA to do their job.
I can enter 1.1.1 into a text box with no quotes and IsNumeric works just find.
If I am in Debug, to enter 1.1.1 not in quotes is incorrect. Is isn't a number, it's a string. It's the same as if I wrote ? Isnumeric(Hi Tom!) I'd expect an error.
I doubt MLH would have gotten an error if he did this var = "1.1.1" ? Isnumeric(var)
The reason I would get an accurate result using an unbound textbox in a form is that Text0, in my opionion, is similar to a variable of type variant.
>> The reason isnumeric(1.2.2 ) fails whereas the other ones MLH mentions succeed is that this one does not convert to a number or a string. The help file says that IsNumeric takes a number or a string. 1.2.2 is neither. That's why it fails.
The only time I can see MLH's error occurring is if he's doing everything from the debug/immediate window. To me, that is a data entry, perhaps logic, error he made in the Debug window. IOW...user error.
The advice he was seeking, as far as I'm concerned, is how does he/she write statements in the Debug window and what to do if the statement is incorrect.
>> -Tom. Microsoft Access MVP
>>>MLH wrote:
I have tested the following in immed window:
?isnumeric( 1) True ?isnumeric( 1.) True ?isnumeric( 1.2) True ?isnumeric( 1.2.2)
The last one does not print True nor False. Instead, A97 complains of a compile error. I would really prefer False, should such be the case. What's the best way not to be bothered with the error and just assume False is returned?
Experimenti ng with CStr was not fruitful because 1.2.2 is neither a valid numeric expressio n nor a valid string expression.
Why is it not a valid string?
So, what can I do if I find myself needing to process ?CStr(1.2.2) in the same way ?CStr("1.2. 2") would be processed.
Put quotes around it. You're in debug, not a form or report or query or table.
If a user enters 1.2.2 in an unbound text- box expecting a valid numeric entry, I would like very much to determine, in code, that it is NOT a valid numeric. But IsNumeric(1.2.2 ) is not the answer and neither is IsNumeric(CStr( 1.2.2)). So what do I do?
I created a form. I added a textbox. In the AfterUpdate event I have the following code. Private Sub Text2_AfterUpda te() If IsNumeric(Me.Te xt2) Then MsgBox "Numeric" Else MsgBox "Alpha" End If End Sub
I entered 1.2.2 and I got "Alpha". Which is correct.
There's a difference between using a form and entering data into an immedicate window.
On Sun, 27 Jul 2008 21:31:35 -0700, Salad <oi*@vinegar.co mwrote:
Your first test I cannot confirm in A2007. If I have an unbound
textbox and an AfterUpdate event:
Private Sub Text47_AfterUpd ate()
Debug.Print Text47.value, IsNumeric(Text4 7)
End Sub
Then it will consistently print:
1.1.1 False
Indeed IsNumeric works fine (no error) and since
I agree that an unbound textbox with value of 1.1.1 will run IsNumeric
just fine and it will return False. I agree we can think of this value
to be of type Variant, but if you test it using VarType, you will find
it is of type String.
I disagree when you say "If I am in Debug, to enter 1.1.1 not in
quotes is incorrect. Is isn't a number, it's a string"
I would argue: no it's not. It's an illegal value. Strings are wrapped
with "".
Isnumeric(Hi Tom!)
is also syntactically incorrect for the same reason.
Isnumeric("Hi Tom!")
is the correct syntax.
Assuming var is a Variant, there would not be an error, but just a
return value of False for var="1.1.1".
-Tom.
>Tom van Stiphout wrote:
>On Sun, 27 Jul 2008 19:50:17 -0700, Salad <oi*@vinegar.co mwrote:
Hi Salad, I don't agree with your assertion "There's a difference between using a form and entering data into an immedicate window" at least when it comes to the performance of IsNumeric. Both environments use the same VBA to do their job.
I can enter 1.1.1 into a text box with no quotes and IsNumeric works just find.
If I am in Debug, to enter 1.1.1 not in quotes is incorrect. Is isn't a number, it's a string. It's the same as if I wrote ? Isnumeric(Hi Tom!) I'd expect an error.
I doubt MLH would have gotten an error if he did this var = "1.1.1" ? Isnumeric(var)
The reason I would get an accurate result using an unbound textbox in a form is that Text0, in my opionion, is similar to a variable of type variant.
>> The reason isnumeric(1.2.2 ) fails whereas the other ones MLH mentions succeed is that this one does not convert to a number or a string. The help file says that IsNumeric takes a number or a string. 1.2.2 is neither. That's why it fails.
The only time I can see MLH's error occurring is if he's doing everything from the debug/immediate window. To me, that is a data entry, perhaps logic, error he made in the Debug window. IOW...user error.
The advice he was seeking, as far as I'm concerned, is how does he/she write statements in the Debug window and what to do if the statement is incorrect.
>> -Tom. Microsoft Access MVP
>>>MLH wrote:
I have tested the following in immed window:
?isnumeric( 1) True ?isnumeric( 1.) True ?isnumeric( 1.2) True ?isnumeric( 1.2.2)
The last one does not print True nor False. Instead, A97 complains of a compile error. I would really prefer False, should such be the case. What's the best way not to be bothered with the error and just assume False is returned?
Experimenti ng with CStr was not fruitful because 1.2.2 is neither a valid numeric expressio n nor a valid string expression.
Why is it not a valid string?
So, what can I do if I find myself needing to process ?CStr(1.2.2) in the same way ?CStr("1.2. 2") would be processed.
Put quotes around it. You're in debug, not a form or report or query or table.
If a user enters 1.2.2 in an unbound text- box expecting a valid numeric entry, I would like very much to determine, in code, that it is NOT a valid numeric. But IsNumeric(1.2.2 ) is not the answer and neither is IsNumeric(CStr( 1.2.2)). So what do I do?
I created a form. I added a textbox. In the AfterUpdate event I have the following code. Private Sub Text2_AfterUpda te() If IsNumeric(Me.Te xt2) Then MsgBox "Numeric" Else MsgBox "Alpha" End If End Sub
I entered 1.2.2 and I got "Alpha". Which is correct.
There's a difference between using a form and entering data into an immedicate window.
On Sun, 27 Jul 2008 19:50:17 -0700, Salad <oi*@vinegar.co mwrote:
>MLH wrote:
>I have tested the following in immed window:
?isnumeric(1 ) True ?isnumeric(1 .) True ?isnumeric(1.2 ) True ?isnumeric(1.2 .2)
The last one does not print True nor False. Instead, A97 complains of a compile error. I would really prefer False, should such be the case. What's the best way not to be bothered with the error and just assume False is returned?
Experimentin g with CStr was not fruitful because 1.2.2 is neither a valid numeric expression nor a valid string expression.
Why is it not a valid string?
>So, what can I do if I find myself needing to process ?CStr(1.2.2) in the same way ?CStr("1.2.2 ") would be processed.
Put quotes around it. You're in debug, not a form or report or query or table.
>If a user enters 1.2.2 in an unbound text- box expecting a valid numeric entry, I would like very much to determine, in code, that it is NOT a valid numeric. But IsNumeric(1.2.2 ) is not the answer and neither is IsNumeric(CStr( 1.2.2)). So what do I do?
I created a form. I added a textbox. In the AfterUpdate event I have the following code. Private Sub Text2_AfterUpda te()
If IsNumeric(Me.Te xt2) Then
MsgBox "Numeric"
Else
MsgBox "Alpha"
End If End Sub
I entered 1.2.2 and I got "Alpha". Which is correct.
There's a difference between using a form and entering data into an immedicate window.
I'd noticed that. But I considered it a glitch! I had no
clue. Why would the Access developers do such a
thing? I mean, the PURPOSE of the Debug Window
the former Immediate Window, I thought, was to test
crap you were gonna use in code! Are there any other
sneaky gotchas like that running around???
I'm not the sharpest tool in the shed, but it
sure seems like Salad has a point.
If I've got Text0 and Text2 textboxes on an
otherwise empty form and Text0 has this AfterUpdate
event property ...
Private Sub Text0_AfterUpda te()
If IsNumeric(Text0 ) Then Text2 = True Else Text2 = False
End Sub
.... I don't get a compile error typing ANY of the following
into Text0 ...
1
1.
1.2
1.2.2
"1.2.2"
.... and pressing ENTER. I get either True or False
(first 3 True, last 2 False). That's certainly a different
than the debug window provides. If the debug window
is using the same VBA that running Access procedures
use = then it's sending different arguments or using a
different part of VBA than procedures in forms are
using. I mean, if you throw the same salad ingrediens
into 2 different black boxes and one spits out a salad
and the other a pizza - well, U-C what I'm saying.
Addiing to your point,
?isnumeric(abcd e)
True
in the immediate window.
But on a form in a textbox it yields False.
Of course, in the form's textbox, abcde
is being viewed as data. And in debug,
well, it's not readily apparent ...
?abcde
?VarType(abcde)
0 (empty, unitialized)
.... which is not the same as vbVariant (12).
So, I don't think there's enough substance
here to base an argument on in either direction.
I don't think what's happening is something
that was carefully planned or intended - or
even addressed for that matter. I think it's a
screw-up & the ADT overlooked it altogether.
MLH wrote:
On Sun, 27 Jul 2008 19:50:17 -0700, Salad <oi*@vinegar.co mwrote:
>>MLH wrote:
>>>I have tested the following in immed window:
?isnumeric(1 ) True ?isnumeric(1 .) True ?isnumeric(1 .2) True ?isnumeric(1 .2.2)
The last one does not print True nor False. Instead, A97 complains of a compile error. I would really prefer False, should such be the case. What's the best way not to be bothered with the error and just assume False is returned?
Experimentin g with CStr was not fruitful because 1.2.2 is neither a valid numeric expression nor a valid string expression.
Why is it not a valid string?
>>>So, what can I do if I find myself needing to process ?CStr(1.2.2) in the same way ?CStr("1.2.2 ") would be processed.
Put quotes around it. You're in debug, not a form or report or query or table.
>>>If a user enters 1.2.2 in an unbound text- box expecting a valid numeric entry, I would like very much to determine, in code, that it is NOT a valid numeric. But IsNumeric(1.2.2 ) is not the answer and neither is IsNumeric(CStr( 1.2.2)). So what do I do?
I created a form. I added a textbox. In the AfterUpdate event I have the following code. Private Sub Text2_AfterUpda te() If IsNumeric(Me.Te xt2) Then MsgBox "Numeric" Else MsgBox "Alpha" End If End Sub
I entered 1.2.2 and I got "Alpha". Which is correct.
There's a difference between using a form and entering data into an immedicate window.
I'd noticed that. But I considered it a glitch! I had no
clue. Why would the Access developers do such a
thing? I mean, the PURPOSE of the Debug Window
the former Immediate Window, I thought, was to test
crap you were gonna use in code! Are there any other
sneaky gotchas like that running around???
If I input incorrect data into the immediate window I'd expect an error.
Garbage in, garbage out. You entered in garbage and expected Access
to fix it.
You were using a literal value that was incorrectly entered. Then you
complain about Access noting the error. Why? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: DCM Fan |
last post by:
SELECT ISNUMERIC('. ')
1
SELECT CAST('. ' AS )
Syntax error converting the varchar value '. ' to a column of data type
.
Any thoughts as to why SQL Server 7.0 considers '. ' to be numeric, yet can't
|
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 following function in a validating class to use
when needed. (Value = H880118A gave the error (like
other 'unconvertible' strings))
Public...
|
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 89.11998811777 and
other values that are simply *NOT* INT values."
<%
function isZip(input)
|
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
|
by: crowl |
last post by:
I have a pocket pc project in c#.
From a textbox i have to verify if the input is numeric. I have found
in the msdn a sample like this: textbox1.numeric = true / false. But
this do not work in my environment.
If I convert the textbox content explicit to a numeric value, and is
is not numeric, the program ran into the error handler (try...
| |
by: martin |
last post by:
Hi,
is there a dotnet function (other than the old isnumeric from VB) to check
whether an object is numeric or not.
also I notice that all the old vb functions such as split / isnumeric /
ubound etc are still availible by default in any VB.net web application.
is this because the vb library is being imported??
would it be best to totally...
|
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 to solve the error.
|
by: michele |
last post by:
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...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |