Re: isnumeric compile error...



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.
.



Relevant Pages

  • Re: isnumeric compile error...
    ... Is isn't a number, it's a string. ... The only time I can see MLH's error occurring is if he's doing everything from the debug/immediate window. ... 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. ... There's a difference between using a form and entering data into an immedicate window. ...
    (comp.databases.ms-access)
  • Returning selected items in an open folder
    ... items in an open folder window. ... Dim boo As Boolean ... '-- s1 is a unique string that's part of a specific open folder path. ... Private Sub Form_QueryUnload ...
    (microsoft.public.vb.general.discussion)
  • Re: Why doesnt this recursive function return the right value?
    ... ByVal WindowTitle As String, _ ... 'finds the first window where the class name start with ClassName ... Dim sWindowTitle As String ...
    (microsoft.public.excel.programming)
  • MultiWindowed Adventure Game
    ... - one for the normal game and one for the status window ... wants the statusConsole application to display in the status window. ... so it's important that you pass the actual string ... use the sharedStr type above and initialize ...
    (alt.lang.asm)
  • Re: Need help with Code Please!!!
    ... I really need to see what the final SQ1 string looks like. ... select View and then "Immediate Window". ...
    (microsoft.public.access.formscoding)