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 winapi: shellexecute - 打开外部程序或文件

Delphi 安卓开发 ioutils文件说明

Delphi之memo组件

Delphi winapi: getnextwindow - 获取指定窗口z上或z下的窗口的句柄

Delphi winapi: loadstring - 从资源中载入字符串

Delphi 获取本机 hostname ip address

Delphi 金额转大写

Delphi中的copy,delete,pos和leftstr,rightstr的用法

Delphi adoconnection断线重连

Delphi检测android mock位置

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



打赏

取消

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

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

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

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

评论

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