if not((key in ['0'..'9']) or (key in[#13, #8])) then Key := #0;
if not((key in ['0'..'9', #13, #8]) ) then Key := #0;
同意楼上,不过楼主要注意是在keypress事件中执行 procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not((key in ['0'..'9', #13, #8]) ) then Key := #0; end;
Key := #0;
Key := #0;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not((key in ['0'..'9', #13, #8]) ) then
Key := #0;
end;