怎样用简单的方法判断文本框的输入的是否是整数?

benben1hao 2003-08-21 05:37:00
怎样用简单的方法判断文本框的输入的是否是整数?
...全文
50 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
overtime 2003-08-21
  • 打赏
  • 举报
回复
function isnum(str:string)
begin
try
strtoint(str)
result:=True;
except
result:=false
end;
end;
delphiplus 2003-08-21
  • 打赏
  • 举报
回复
tryStrToInt 也可以
AustinLei 2003-08-21
  • 打赏
  • 举报
回复
这个也不错,如果字符串不是整数不会报错。
function IsIntStr(const S: string): boolean;
begin
Result:=StrToIntDef(S,0)=StrToIntDef(S,1);
end;
DWGZ 2003-08-21
  • 打赏
  • 举报
回复
用这个两个比较好
function IsInt(AStr: string): Boolean;
var
Value, Code: Integer;
begin
Val(AStr, Value, Code);
Result := Code = 0;
end;

function IsFloat(AStr: string): Boolean;
var
Value: Real;
Code: Integer;
begin
Val(AStr, Value, Code);
Result := Code = 0;
end;
charles2118 2003-08-21
  • 打赏
  • 举报
回复
try
s:=strToInt(youNumber)
except
showmessage('not integer')
fengjn 2003-08-21
  • 打赏
  • 举报
回复
var a: real;
begin
try
a:= strtofloat(edit1.text) ;
except
不是数
end;
if round(a) = a then
整数 else
小数
end;
mysqlcom 2003-08-21
  • 打赏
  • 举报
回复
搜索一下以前的贴啊。

5,388

社区成员

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

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