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 封装的tidhttp get post 请求

Delphi实现阿里云印刷文字识别_身份证识别

Delphi copyrect实现的几个图片的转换效果

Delphi idhttp中get 图像链接通过memorystream加载 image控件显示

Delphi实现身份证号码15到18位升位算法

Delphi 常用4种对话框

Delphi 字符串转换ascii码10进制

Delphi 移位函数

webbrowser里网页根据文字判断来点击链接

Delphi 命令行程序调用单元函数

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



打赏

取消

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

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

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

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

评论

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