• SetEditOnePoint() 使Edit控件中只能输入数字和1个小数点



    {使Edit控件中只能输入数字和1个小数点 }
    // 调用 放在Edit的KeyPress事件下 setOnePoint(Key,Edit1);
    procedure SetEditOnePoint(var Key: Char;CTRL:Tedit);
    var p:integer; tp:TPoint;
    begin
       if key in['0'..'9','+','-','.'] then
          begin
             if key in['+','-'] then
                 begin
                   p:=pos('+',CTRL.Text)+pos('-',CTRL.Text);
                   if p>0 then
                      key:=#0
                   else
                      begin
                         GetCaretPos(tp);
                         if tp.x>1 then key:=#0;
                      end;
                 end
             else  if key='.' Then
                 begin
                    p:=pos('.',CTRL.Text);
                    if p>0 then key:=#0;
                 end;
          end
       else if key>#31 then key:=#0;
    end;




  • 相关阅读:
    Active Report 3 生成图表
    js asp.net enable/disable validator
    [.net] 如何在mail的加入正文显示图片
    [javascript] 得到 javascript 的当前文件名
    Colorful Stones
    Jam的计数法

    Beautiful Matrix
    能量项链
    Maxim and Discounts
  • 原文地址:https://www.cnblogs.com/xe2011/p/2609330.html
Copyright © 2020-2023  润新知