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

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即可

posted @ 2011-03-01 20:48  吴越  阅读(158)  评论(0编辑  收藏  举报