49 lines
1.1 KiB
Text
49 lines
1.1 KiB
Text
isnumeric
|
|
$Typecheck on
|
|
|
|
Defint FALSE, TRUE
|
|
|
|
FALSE = 0
|
|
TRUE = NOT FALSE
|
|
|
|
Function isNumeric(s as string, optchar as string) as integer
|
|
If len(s) = 0 then
|
|
Result = FALSE
|
|
Exit Function
|
|
End If
|
|
if instr(s,"+") > 1 then
|
|
Result = FALSE
|
|
exit function
|
|
end if
|
|
if instr(s,"-") > 1 then
|
|
Result = FALSE
|
|
exit function
|
|
end if
|
|
Defint i, ndex = 0
|
|
For i = 1 to len(s)
|
|
select case asc(mid$(s,i,1))
|
|
case 43 '+
|
|
case 45 '-
|
|
case 46 '.
|
|
if ndex = 1 then
|
|
Result = FALSE
|
|
Exit function
|
|
end if
|
|
ndex = 1
|
|
case 48 to 57 '0 to 9
|
|
case else
|
|
if instr(optchar,(mid$(s,i,1))) = 0 then
|
|
Result = FALSE
|
|
exit function
|
|
end if
|
|
end select
|
|
next
|
|
Result = TRUE
|
|
End Function
|
|
|
|
'============================================================
|
|
'Begin
|
|
'============================================================
|
|
|
|
showmessage (str$(isNumeric("-152.34","")))
|
|
end
|