美哟,直接 SetWindowLong(Edit1.Handle, GWL_STYLE, GetWindowLong(Edit1.Handle, GWL_STYLE) or ES_NUMBER); 就可以了
onkeypress if not (key in ['0'..'9',#8]) then key:=#0;
*******onkeypress ***********if Key = #8 then exit; if (Key < '0') or (Key > '9') then Key := #10;
你可以利用控件的涵数 procedure TForm1.editKeyPress(Sender: TObject; var Key: Char); begin if (k>='0') and (k<='9') or (k=chr(8)) or (k=chr(13)) then else begin k:=chr(0); beep; end; end;
SetWindowLong(Edit1.Handle, GWL_STYLE,
GetWindowLong(Edit1.Handle, GWL_STYLE) or
ES_NUMBER);
就可以了
if not (key in ['0'..'9',#8]) then
key:=#0;
exit; if (Key < '0') or (Key > '9') then Key := #10;
procedure TForm1.editKeyPress(Sender: TObject; var Key: Char);
begin
if (k>='0') and (k<='9') or (k=chr(8)) or (k=chr(13))
then
else
begin
k:=chr(0);
beep;
end;
end;