您的位置:首页 > 其它

IsNumeric 判断字符串是否为数字

2013-06-24 13:56 190 查看
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; 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐