Re: isnumeric compile error...



On Sun, 27 Jul 2008 19:50:17 -0700, Salad <oil@xxxxxxxxxxx> wrote:

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.

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



Relevant Pages

  • Re: isnumeric compile error...
    ... A97 complains of a compile error. ... Private Sub Text2_AfterUpdate ... MsgBox "Numeric" ... I entered 1.2.2 and I got "Alpha". ...
    (comp.databases.ms-access)
  • Re: Search Feature
    ... When I replaced the code it gives me a VB Compile Error: ... Dim strSearch As String ... 'Check txtSearch for Null value or Nill Entry first. ... MsgBox "Please enter a value!", vbOKOnly, "Invalid Search ...
    (microsoft.public.access.forms)
  • Re: ADO -DAO problem?
    ... example MsgBox.Name) will return public_banker 'cause ... public_banker is the first field in your data collection and the index begin ... I have again a compile error: invalid use of property on ...
    (microsoft.public.access.modulesdaovba)
  • Re: worksheet_calculation problem
    ... Private Sub Worksheet_Calculate ... MsgBox "Please enter correct postal code" ... then changes code for sheetas follow: ... and now I get a compile error: Copmile error in hidden module: hseet 4 ...
    (microsoft.public.excel.programming)