如何判断用户输入的是数字还是字符串,如果是数字能否判断是整数还是小数

mahaixing 2003-04-03 09:22:51
如题
...全文
206 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wudi_1982 2003-04-03
  • 打赏
  • 举报
回复
StrToFloatDef有这儿东东吗?

应该是 StrToIntDef吧。
sysu 2003-04-03
  • 打赏
  • 举报
回复
if StrToFloatDef(s, 0) = StrToFloatDef(s, 1) then
if StrToIntDef(s, 0) = StrToIntDef(s, 1) then
ShowMessage('整数')
else
ShowMessage('浮点数')
else
ShowMessage('不是数字');
firstshine 2003-04-03
  • 打赏
  • 举报
回复
if StrToFloatDef(Edit1.Text,-1)<>StrToFloatDef(Edit1.Text,-2) then
ShowMessage('That''s not a float');


if StrToIntDef(Edit1.Text,-1)<>StrToIntDef(Edit1.Text,-2) then
ShowMessage('That''s not a Integer');
wudi_1982 2003-04-03
  • 打赏
  • 举报
回复
try
strtoint(str);
except

end;

try
StrToFloat(str);
except

end;
hyfyxu 2003-04-03
  • 打赏
  • 举报
回复
用ASCII码判断也不麻烦了吧!
zhptj 2003-04-03
  • 打赏
  • 举报
回复
楼上的有道理
不过你也可以用他们的码来判断
guestman 2003-04-03
  • 打赏
  • 举报
回复
try
strtoint(lpstr);
except
showmessage('不是整数');
end;

try
StrToFloat(lpstr);
except
showmessage('不是小数');
end;

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧