什么函数,可以判断字符串能被转化成double型?

来源:互联网 发布:苹果windows系统安装 编辑:程序博客网 时间:2024/06/05 09:14

1:trystrtofloat(str,float): boolean
2:trystrtofloat(str,float): boolean 这个函数在delphi中找不到。
3:function TryConvertStringToFloat(str: string):Boolean;
begin
Result := False;
try
StrToFloat(str);
Result := True;
except
Result := False;
end;
end;
4:妙,就像txmaster这样做,其他的也可以类似这样判断。
5:if StrToFloatDef(str,-999)=-999 then showmessage('失败');
6:用Try不可取, StrToInt 或StrToFloat 有位数限制,如100个"9",虽然都是数字但不能得到正确结果.下面的是我写的:
function IsNumber(Str: string): Boolean; //Str是否数字
var
I: Integer;
begin
Result := True;
for I := 1 to Length(Str) do
begin
if (Ord(Str[I])

原创粉丝点击