I have very strange problem with IsNumeric function in classic asp fail. Something like this happens in my code:
Response.write Score // 79.617
Response.write IsNumeric(Score) // false
Response.write IsNumeric("79.617") // true
Has anyone had an idea why this could happen?
In the specifications it is said that the functions works with strings that can be converted into numbers, and from the example above you can see i get "true" result. But what can then cause my issue?
This means Score
is simply not a string but rather something else, most likely coming from database.
To be on the safe side, use your own function:
Function My_IsNumeric(value)
My_IsNumeric = False
If IsNull(value) Then Exit Function
My_IsNumeric = IsNumeric(CStr(value))
End Function
Response.write My_IsNumeric(Score)
The CStr()
will make sure to convert anything except Null to a string, and to handle Null coming from database you have the IsNull()
function.