Re: isnumeric compile error...
- From: Tom van Stiphout <no.spam.tom7744@xxxxxxx>
- Date: Sun, 27 Jul 2008 21:37:25 -0700
On Sun, 27 Jul 2008 21:31:35 -0700, Salad <oil@xxxxxxxxxxx> wrote:
Tom van Stiphout wrote:.
On Sun, 27 Jul 2008 19:50:17 -0700, Salad <oil@xxxxxxxxxxx> wrote:
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?
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_AfterUpdate()
If IsNumeric(Me.Text2) 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.
- References:
- isnumeric compile error...
- From: MLH
- Re: isnumeric compile error...
- From: Salad
- Re: isnumeric compile error...
- From: Tom van Stiphout
- Re: isnumeric compile error...
- From: Salad
- isnumeric compile error...
- Prev by Date: Re: isnumeric compile error...
- Next by Date: Re: isnumeric compile error...
- Previous by thread: Re: isnumeric compile error...
- Next by thread: Re: isnumeric compile error...
- Index(es):
Relevant Pages
|