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中的record怎么动态分配内存?

Delphi 分解时间 �cdecodedate、decodetime … decodedatetime …

Delphi txt 指定行复制器

Delphi 建立最小的应用程序

Delphi idftp 使用被动连接

Delphi 数据集转换json对象

Delphi now 返回当前日期及时间

Delphi抓取qq聊天窗口实例

Delphi 获取内核地址的简单方法

Delphi splitter 控件属性及作用

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



打赏

取消

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

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

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

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

评论

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