用函数判断呀, function IsDigit(Str:String):boolean; begin result:=true; try StrToInt(Str); except result:=false; end; end; if IsDigit(Edit1.Text) then ... else ...
帮你搞定: 在edit的onkeypress中 if ((key<'0') or (key>'9')) and (key<>'.') and (key<>#13) and (key<>#8) then begin application('',''); abort; end; 应该很全了。
begin
if not ((key >= '0') and (key <= '9')) then
if (key <> #8) then
key := #0;
end;
你这样做可以达到目的,,但又带来新的问题如果用户用使用删除键怎么办
if not ((key >= '0') and (key <= '9')) then////
if (key <> #8) then//#8是哪个键的代码?先杳一下。。
begin
if not ( key in ['0'..'9',#8] )then
key := #0;
end;
if not ( key in ['0'..'9',#8] )then
key := #0;
end; 同意,这种方法是如何来判断 是否输入的是数字
添加 ES_NUMBER 的风格
为什么不用MaskEdit,最简单了,一行代码也不用写
----------------------------------------------
UPUPUPUPUPUPUPU.
function IsDigit(Str:String):boolean;
begin
result:=true;
try
StrToInt(Str);
except
result:=false;
end;
end;
if IsDigit(Edit1.Text) then
...
else
...
在edit的onkeypress中
if ((key<'0') or (key>'9')) and (key<>'.') and (key<>#13) and (key<>#8) then
begin
application('','');
abort;
end;
应该很全了。