begin
If not (key in [#48..#57,#8]) then //#8是退格键,也可以加上#13回车键
begin
showmessage('只能输入数字');
key:= #0;
end;
end;
procedure Tform_zc.edit_dhKeyPress(Sender: TObject; var Key: Char);
begin
if not (key in ['0'..'9',#8]) then
begin
showmessage('输入数字');
key:=#0;
end;