限定只能输入数字和小数点

    技术2022-05-20  31

    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);begin     case Key of    '0'..'9', #8, #13, #27, '.' : ;  else    begin      MessageBox(Handle, '请输入数字', PChar('输入错误'), MB_OK + MB_ICONINFORMATION);      Key := #0;    end;  end;

    end;

     

    //只能输入数字和小数点,

    //只需要编写edit1的KeyPress事件,edit2的KeyPress事件在下拉菜单选择 Edit1KeyPress即可

     


    最新回复(0)