How to determine if an entry is a character or number

D

DontKnow

hi Guys,

I need a way to determine if an single entry is a character or is a number...

Please helpme!!

Cheers
 
J

John W. Vinson

hi Guys,

I need a way to determine if an single entry is a character or is a number...

Please helpme!!

Cheers

Well, a number *is* a character...

The IsNumeric() function will return TRUE if its string argument is a valid
number: e.g. IsNumeric("345") is True, IsNumeric("a45") is false.

There's a tricky little "gotcha" though: if the argument is a valid number in
the old, old Fortran Floating Point notation, such as "31E5" or "2D30"
(corresponding to 31 * 10^5 or 2 * 10^30) it will be true, though you might
consider these to be text.
 
M

Marshall Barton

DontKnow said:
I need a way to determine if an single entry is a character or is a number...


If Me.textbox Like "[a-z]" Then
' it's a letter
ElseIf Me.textbox Like "[0-9]" Then
' it's a number
Else
' it's something else
End If
 
D

DontKnow

Thnaks mate!!

Thats exactly what I want, I'll do a string search for the rogue "D" or "E"
using the "instr" function


Many thnaks again!!

cheers,
 
M

Marshall Barton

Alternatively:

If Me.textbox Like "*[!0-9]*" Then
' text box contains a non-decimal digit
Else
' text box contains only decimal digits
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top