delphi Edit只允许输入数字和小数点


本文整理自网络,侵删。

 
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);

var
i:Integer;
begin
if (Key = '.') and (Length(Edit1.Text) > 0) then  //处理小数点
  begin
    for i := 1 to length(Edit1.text) do
    begin
      if Edit1.Text[i] = '.' then Key := #0;
    end;
  end
  else
  begin
    if not (Key in ['0'..'9',#8]) then Key := #0;  //处理非数字
  end;
end;

相关阅读 >>

Delphi 批量把图片保存到access数据库

Delphi实现拖动无标题窗口的5种方法

Delphi 获取当前系统版本号

Delphi 遍历某字段并插入到combobox

Delphi tms web core messagedlg对话框 yes no

Delphi 主线程等待子线程的安全退出

Delphi 解决timage无法在窗体resize时改变canvas的大小

Delphi android 获取通�记录

Delphi 程序嵌入桌面效果的实现

Delphi ifdef 另类用法

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...