怎么判断edit输入的数据类型 我想要判断edit.text的数据类型是否为数字型的 如果不是就不能操作 请问要怎么判断? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //自定义的函数,isFloatfunction isFloat(aStr):boolean;begin try StrToFloat(aStr); result:=true; except result:=false; end;end;if IsFloat(Edit1.Text) then ShowMessage(Edit1.Text+'是数字')else ShowMessage(Edit1.Text+'不是数字');-----------------------------------http://www.kmok.cn/ 1楼的是输入后才判断,还是可以输入的。比较人性化的设计是在keypress中判断用户按下的按键,对输入进行限制。这样就只能输入数字\符号\小数点。用户感觉比较舒服。网上一大堆代码的。 在 Edit 的 KeyPress 事件中加入下列代码: if not((key in ['0'..'9',#8]) ) then begin showmessage ('不是数字'); key := #0; end; var I, Code: Integer;begin Val(Edit1.Text, I, Code); if Code <> 0 then Showmessage('不是整数') else Showmessage('是整数');end; var A : Float; if tryStrToFloat(Edit1.text,A) then ShowMessage('全是數字') else ShowMessage('錄入數據不合法'); 这个技术叫什么名字? 关于Delphi在WindowXP SP2 下的问题 过年散分2 一个错误。。。 请教各位大侠,怎么才能即时输入文字那?(想了好久的问题,问过很多人都不能彻底回答) 正在開發人事考勤薪資系統﹐各位大哥提點意見。 http1.1和http1.0? Delphi的指数函数X的Y次方是什么? 高分请教高手ShellExecute函数中调用程序的Handle问题 关于制作可停靠窗口的问题 当dll中的函数返回类型为Tstrings 时,程序调用内存出错,如何解决? Delphi 如何能快速的导出Excel数据?
function isFloat(aStr):boolean;
begin
try
StrToFloat(aStr);
result:=true;
except
result:=false;
end;
end;if IsFloat(Edit1.Text) then
ShowMessage(Edit1.Text+'是数字')
else
ShowMessage(Edit1.Text+'不是数字');
-----------------------------------
http://www.kmok.cn/
比较人性化的设计是在keypress中判断用户按下的按键,对输入进行限制。
这样就只能输入数字\符号\小数点。
用户感觉比较舒服。网上一大堆代码的。
if not((key in ['0'..'9',#8]) ) then
begin
showmessage ('不是数字');
key := #0;
end;
var I, Code: Integer;
begin
Val(Edit1.Text, I, Code);
if Code <> 0 then
Showmessage('不是整数')
else
Showmessage('是整数');end;
A : Float; if tryStrToFloat(Edit1.text,A) then
ShowMessage('全是數字')
else
ShowMessage('錄入數據不合法');