This version takes only 1 parameter - input can be integer or float, signed or unsigned, with or without comma-separators.
It returns just 2 values: 1 (true) or 0 (false).
NOTE: Hexadecimal numbers and scientific notations are not taken into account - if they are used as input, the function will return false.
Let me know if you find any valid numbers that is being flagged as not numeric as well as any invalid numbers that is passing as numeric.
I found that there are already several versions of IsNumeric() posted here, but anyways here my spin on it

Code: Select all
Procedure IsNumeric(String.s)
;remove any leading and/or trailing spaces
string = Trim(string)
;we expect the +/- sign at the beginning of the string only
;remove leading positive sign if present
If Left(string,1) = "+"
string = Right(string, Len(string)-1)
;extra + or - signs make the string not a valid numeric
If FindString(string, "+", 1) > 0 Or FindString(string, "-", 1) > 0
ProcedureReturn #False
EndIf
EndIf
;remove leading negative sign if present
If Left(string,1) = "-"
string = Right(string, Len(string)-1)
;extra + or - signs make the string not a valid numeric
If FindString(string, "+", 1) > 0 Or FindString(string, "-", 1) > 0
ProcedureReturn #False
EndIf
EndIf
;valid numbers can have only 1 dot for the decimal point if used, so we're checking for that
dotCt = CountString(String, ".")
;multiple dots in the string make it non-numeric
If dotCt > 1
ProcedureReturn #False
EndIf
;in the absence of a decimal point, we evaluate the remaining string
If dotCt = 0
;check for comma separators
If FindString(string, ",", 1) > 0
leftPart.s = string
;check that we have the right number of commas
commaCt = CountString(leftPart, ",")
noCommaString.s = ReplaceString(leftPart, ",", "")
expectedCommaCt = Len(noCommaString) / 3
If Len(noCommaString) % 3 = 0
expectedCommaCt = expectedCommaCt - 1
EndIf
If commaCt <> expectedCommaCt
ProcedureReturn #False
EndIf
;Find the position of all commas
Dim commaPos(commaCt)
commaPos(0) = FindString(leftPart, ",", 1)
For x=1 To commaCt-1
commaPos(x) = FindString(leftPart, ",", commaPos(x-1)+1)
;if there are multiple commas, there should be 3 digits in between succeeding commas
If commaPos(x) - commaPos(x-1) <> 4
ProcedureReturn #False
EndIf
Next x
;string have commas in the right positions, now check the chars in the string if they are digits or a comma
For x=1 To Len(leftPart)
If FindString("1234567890,", Mid(leftPart, x, 1), 1) = 0
ProcedureReturn #False
EndIf
Next x
;if comma separators were used properly, remove them before any further validations are done
string = ReplaceString(leftPart, ",", "")
EndIf
;if empty string or sign only (+ or -) was passed
If string = ""
ProcedureReturn #False
EndIf
If string = RSet(Str(Val(string)), Len(string), "0")
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndIf
;if valid decimal point is present, we evaluate the portions before and after the decimal point separately
If dotCt = 1
;if there's nothing in the string but the dot; it's not a number
If Len(string)=1
ProcedureReturn #False
EndIf
;split the string into the parts before and after the decimal point
dotPos = FindString(String, ".", 1)
leftPart.s = Left(String, dotPos-1)
rightPart.s = Right(String, Len(String)-dotPos)
;there should be no comma separator in the decimal portion of any valid number
If FindString(rightPart, ",", 1) > 0
ProcedureReturn #False
EndIf
;check for comma separators
If FindString(leftPart, ",", 1) > 0
;check that we have the right number of commas
commaCt = CountString(leftPart, ",")
noCommaString.s = ReplaceString(leftPart, ",", "")
expectedCommaCt = Len(noCommaString) / 3
If Len(noCommaString) % 3 = 0
expectedCommaCt = expectedCommaCt - 1
EndIf
If commaCt <> expectedCommaCt
ProcedureReturn #False
EndIf
;Find the position of all commas
Dim commaPos(commaCt)
commaPos(0) = FindString(leftPart, ",", 1)
For x=1 To commaCt-1
commaPos(x) = FindString(leftPart, ",", commaPos(x-1)+1)
;if there are multiple commas, there should be 3 digits in between succeeding commas
If commaPos(x) - commaPos(x-1) <> 4
ProcedureReturn #False
EndIf
Next x
;string have commas in the right positions, now check the chars in the string if they are digits or comma
For x=1 To Len(leftPart)
If FindString("1234567890,", Mid(leftPart, x, 1), 1) = 0
ProcedureReturn #False
EndIf
Next x
;if comma separators were used properly, remove them before any further validations are done
leftPart = ReplaceString(leftPart, ",", "")
EndIf
If leftPart = RSet(Str(Val(leftPart)), Len(leftPart), "0")
If rightPart = RSet(Str(Val(rightPart)), Len(rightPart),"0")
;the parts of the string before and after the decimal point are both numeric
ProcedureReturn #True
Else
;the part of the string after the decimal point is not numeric
ProcedureReturn #False
EndIf
Else
If leftPart = "" And Left(string,1) = "."
If rightPart = RSet(Str(Val(rightPart)), Len(rightPart),"0")
;the remaining string begins with a decimal point and everything after that is numeric
ProcedureReturn #True
EndIf
Else
;the part of the string before the decimal point is not numeric
ProcedureReturn #False
EndIf
EndIf
EndIf
EndProcedure
Code: Select all
Debug "UNSIGNED NUMBERS"
Debug IsNumeric("0")
Debug IsNumeric("1")
Debug IsNumeric(".0")
Debug IsNumeric(".1")
Debug IsNumeric("0.0")
Debug IsNumeric("0.1")
Debug IsNumeric("1.0")
Debug IsNumeric("1.1")
Debug IsNumeric("0.")
Debug IsNumeric("1.")
Debug ""
Debug "NEGATIVE SIGNED NUMBERS "
Debug IsNumeric("-0")
Debug IsNumeric("-1")
Debug IsNumeric("-.0")
Debug IsNumeric("-.1")
Debug IsNumeric("-0.0")
Debug IsNumeric("-0.1")
Debug IsNumeric("-1.0")
Debug IsNumeric("-1.1")
Debug IsNumeric("-0.")
Debug IsNumeric("-1.")
Debug ""
Debug "POSITIVE SIGNED NUMBERS "
Debug IsNumeric("+0")
Debug IsNumeric("+1")
Debug IsNumeric("+.0")
Debug IsNumeric("+.1")
Debug IsNumeric("+0.0")
Debug IsNumeric("+0.1")
Debug IsNumeric("+1.0")
Debug IsNumeric("+1.1")
Debug IsNumeric("+0.")
Debug IsNumeric("+1.")
Debug ""
Debug "NUMBERS PADDED WITH ZERO(S)"
Debug IsNumeric("01")
Debug IsNumeric("+01")
Debug IsNumeric("+01.")
Debug IsNumeric("-01")
Debug IsNumeric("-01.")
Debug IsNumeric("+01.0")
Debug IsNumeric("+01.1")
Debug IsNumeric("-01.0")
Debug IsNumeric("-01.1")
Debug ""
Debug "NUMBERS WITH COMMA SEPARATORS"
Debug IsNumeric("1,000")
Debug IsNumeric("10,000")
Debug IsNumeric("100,000")
Debug IsNumeric("1,000,000")
Debug IsNumeric("1,000.00")
Debug IsNumeric("10,000.00")
Debug IsNumeric("100,000.00")
Debug IsNumeric("1,000,000.00")
Debug IsNumeric("-1,000")
Debug IsNumeric("-1,000,000.00")
Debug ""
Debug "INVALID NUMBERS"
Debug IsNumeric(".")
Debug IsNumeric("+.")
Debug IsNumeric("-.")
Debug IsNumeric("1+")
Debug IsNumeric("1-")
Debug IsNumeric("+-1")
Debug IsNumeric("+-1.0")
Debug IsNumeric("1.0.0")
Debug IsNumeric("abc")
Debug IsNumeric("-1.5E-7")
Debug IsNumeric("1.000,123")
Debug IsNumeric("123456789,")
Debug IsNumeric("12345678,9")
Debug IsNumeric("1234567,89")
Debug IsNumeric("123456,789")
Debug IsNumeric("123,456789")
Debug IsNumeric("12,3456,789")
Debug IsNumeric(",123,456,789")
Debug IsNumeric("-")
Debug IsNumeric("+")
Debug IsNumeric("")