在onkeypress事件中输入 if not (key in ['0'..'9',#8]) then key:=#0;
在文本框中找到其onkeypress 的方法,例如下面的edit例子procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if (key>'A') and (key<'z') then key:=chr(0); end;
在onkeypress事件中输入 if not (key in ['0'..'9',#8]) then key:=#0;
类似的问题不是前面有很多嘛, 在KeyPress 事件中处理 if not (key in 数字 then key:=#0;
if not (key in ['0'..'9',#8]) then key:=#0;
begin
if (key>'A') and (key<'z') then
key:=chr(0);
end;
if not (key in ['0'..'9',#8]) then key:=#0;
在KeyPress 事件中处理
if not (key in 数字 then key:=#0;
在keypress事件中:
try
i:=strtoint(edit1.text);
except
abort;
end;