请问有没有函数判断一个字符串是否是数字
如输入“123”则返回是
输入“123abc”则返回不是
如输入“123”则返回是
输入“123abc”则返回不是
解决方案 »
- 求助:分布式数据库结构连接问题?
- 关于TreeView:如何选定动态增加的Node?
- 急!!!!打开某个窗口时报Access Violation at address ‘’ Read of address ‘’
- 应聘
- 怎样更改文件的时间戳? 创建时间,修改时间,访问时间--(文件/目录)
- OH...一个关于多线程ADOConnect的问题
- 百万求横批!
- 急救,用WordApplication组件如何Open一个文档
- 最新调查!
- 高分求救:能够实现字幕渐出的完整程序(回答者均有分)
- 请问,有什么好的工具可以下载再线电影?
- abc.mdb中有密码为abcd,如何在程序中加入密码,而不使用系统代的密码输入界面?
begin
try
number := StrToInt(str);
result := true;
except
result := false;
end;
end;
false
else
true;
StrToInt('123');
result := true;
except
on E:EConvertError do
result := false;
end;
str1: string;
i: integer;
begin
str1 := Edit1.Text;
for i:=1 to length(str1) do
begin
if str[i] in ['0'..'9'] then
Flag := True;
else
begin
ShowMessage('不是数字');
Flag := False;
Break;
end;
...
end;
首先分析小数点的个数是否大于1,大于1,当然就不是数,反之就遍历字符串,逐个分析字符串中每一个字符的ASII码是不是在0和9之间,或是小数点。