if not(key in['0'..'9',#8]) then
begin
key:=#0;
messagebeep(1);
showmessage('密码只能为数字' )
end;
******************************************
e:= (Sender as TEdit); //需要限制输入的控件可共享这段代码
if not(key in [#48..#57,'.','-',#8]) //可接受的字符
or(key='-')and(e.SelStart>0) //负号只能在串首
or(key='.')and(pos( '.',e.Text)>0)then key:=#0; //只接受一个小数点
***************************************
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in ['0'..'9',Chr(VK_BACK),Chr(VK_Delete)]) then
begin
key:=#0;
Messagebeep(0);
end;
end;
在edit中有选择的输入
最新推荐文章于 2024-09-19 14:32:32 发布