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 不用控件用函数实现发email

Delphi中根据程序名称判断是否多开

Delphi tnethttpcleint提交json串

Delphi 流与字符串

Delphi datasettojson

Delphi 设置打印机 纸张大小! 也可以获取纸张大小

Delphi 6句代码实现Delphi动态调用api函数

Delphi 实现窗口与任务栏右下角对齐

Delphi 去掉twebbrowser的滚动条

Delphi如何计算一个文件目录的大小

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



打赏

取消

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

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

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

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

评论

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