Recently, a post on the AspMessageBoard.com triggered a thread about why the built-in IsNumeric() function returned True for the value "33e1".
The answer is because 33e1 is scientific notation for a larger number. But, unfortunately the database didn't care for this "number" much and returned an error during the insert.
So, I set out to write a simple IsNumeric() function replace. This is what I came up with:
Function myIsNumeric(var)
Dim bOut
Dim dTMP
bOut = IsNumeric(var)
If bOut Then
dTMP = CDbl(var)
bOut = CBool(Trim(dTMP & "") = Trim(var & ""))
End If
myIsNumeric = bOut
End Function
And, to use the function, you would do:
thevar = "22"
thevar = "4333d4"
If myIsNumeric(thevar) Then
Msgbox "it is"
Else
Msgbox "not"
End If
|