Home > Archive > Visual Basic > May 2004 > IsNumeric Replacement
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
IsNumeric Replacement
|
|
| Wes Spikes 2004-05-29, 2:30 pm |
| Does anyone know of a replacement for IsNumeric. I'm trying to check if a
standard number is valid. It doesn't have trouble with 1.1, 1 or any other
number that is >1 but if I try 0.1, I get an error.
A while ago I saw (I believe it was on an MVPs.org page) a replacement
entitled IsNumber. Does anyone know about how well it works and where I can
find it.
-Wes
| |
| Rick Rothstein 2004-05-29, 2:30 pm |
| > Does anyone know of a replacement for IsNumeric. I'm trying to check
if a
> standard number is valid. It doesn't have trouble with 1.1, 1 or any
other
> number that is >1 but if I try 0.1, I get an error.
>
> A while ago I saw (I believe it was on an MVPs.org page) a replacement
> entitled IsNumber. Does anyone know about how well it works and where
I can
> find it.
Here is a function that I've posted in the past... were you perhaps
thinking of it:
Function IsNumber(ByVal Value As String) As Boolean
' Leave the next statement out if you don't
' want to provide for plus/minus signs
If Value Like "[+-]*" Then Value = Mid$(Value, 2)
IsNumber = Not Value Like "*[!0-9.]*" And _
Not Value Like "*.*.*" And _
Len(Value) > 0 And Value <> "."
End Function
and here is the digits-only test (also posted previously):
Function IsDigitsOnly(Value As String) As Boolean
IsDigitsOnly = Not Value Like "*[!0-9]*" And _
Len(Value) > 0
End Function
Rick - MVP
|
|
|
|
|