When I test a string variable to see if it is numeric, I have one case where the answer is wrong (at least at what I am doing - it could be right under other circumstances).
var tstr as boolean
var acctNo as string = “1234A567”
tstr = isNumeric(acctNo)
Returns “FALSE”.
var acctNo as string = “1234E567”
Returns “TRUE”.
I know what is happening - the “E” is interpreted as engineering notation. Other than cycling through the variable to check the ASCII value of each character, how can I determine if the variable includes only the numbers 0 to 9?
Kem - many, many thanks. I didn’t know w hat a RegEx was but tried your code and played with it substituting search pattern commands. What a powerful tool!
Just for the sake of general information, a floating-point number is compound of 2 parts (like 1234e567), a Significand (or Mantissa) part (as 1234) and the Exponent part (as 567, that means x10⁵⁶⁷). So the “E” is the divider sign showing the “here starts the Exponent”. This kind of notation is called Scientific Notation.
Alberto - I hadn’t considered other notations such as “&” which, like “E”, would appear as numeric to the [isNumeric] function. Thanks for the info - the RegEx option solved my problem as suggested by Ken Tekinay. It’s amazing how many things I don’t know!