'Test a string as numeric. opt=1 allows decimals Function IsNumeric(a$,opt As Integer) As Integer If a$="" Then Exit Function Local Integer n,Dots Local q$,c$ If opt Then q$=" 0123456789." Else q$=" 0123456789" For n=1 To Len(a$) c$=Mid$(a$,n,1) If Instr(q$,c$)<2 Then Exit Function Dots=Dots+(c$=".") Next IsNumeric=(Dots<=1) End Function
'Test a string as numeric using regular expressions. opt=1 allows decimals Function IsNumeric(a$,opt As Integer) As Integer If a$="" Then Exit Function Local q$ If opt Then q$="^[0123456789]*\.?[0123456789]*$" Else q$="^[0123456789]*$" IsNumeric=RegExp(q$,a$) End Function