IsNumeric 判断字符串是否为数字(使用Val函数实现),这个函数相当于Java的IsNaN函数

IsNumeric 判断字符串是否为数字,如果是数字返回true,如果包含有汉字或字符的话返回false. 由于Delphi本身没有IsNumeric这个函数,不像其它语言,这个函数相当于Java的IsNaN函数。

delphi代码
function IsNumeric(AStr: string): Boolean; 
var 
Value: Double; 
Code: Integer; 
begin 
Val(AStr, Value, Code); 
result := Code = 0; 
end;
____________________________________________________________________________________________
方法二:
function StrCheck(RemitStr: string): string;
var
VV:string;
begin
if StrToFloatDef(RemitStr,0)<>0 then
Result:=''
else
begin
VV:= RemitStr;
VV:=StringReplace(VV, '0', '', [rfReplaceAll, rfIgnoreCase]);
VV:=StringReplace(VV, '.', '', [rfReplaceAll, rfIgnoreCase]);
if Length(trim(VV))>0 then
Result:=RemitStr;
end;
end; 
---------------------
作者:清风古韵
来源:CSDN
原文:https://blog.csdn.net/ttpage/article/details/9161719
版权声明:本文为博主原创文章,转载请附上博文链接!