我想在EDIT中只能输入数字 要怎么办

解决方案 »

  1.   

    {使该编辑框只能输入数字类型的数据}
     if (edit3.Text='') and (key='.') then
       begin
        key:=#0;
        exit;
       end;
     if (edit3.text='0') and not (key in ['.',#8,#13,#27]) then
       begin
        key:=#0;
        exit;
       end;
     if (pos('.',edit3.text)>0) and (key='.') then
      begin
        key:=#0;
        exit;
      end;
      if not (key in ['0'..'9','.',#8,#13,#27]) then
        key:=#0;
      

  2.   

    方法好多啊,以前只知道一个,现在…………呵呵。学习ing
      

  3.   

    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
       if not (key in ['0'..'9',#8,#13]) then
         key :=#0
    end;
      

  4.   


     if (edit3.Text='') and (key='.') then
       begin
        key:=#0;
        exit;
       end;
     if (edit3.text='0') and not (key in ['.',#8,#13,#27]) then
       begin
        key:=#0;
        exit;
       end;
     if (pos('.',edit3.text)>0) and (key='.') then
      begin
        key:=#0;
        exit;
      end;
      if not (key in ['0'..'9','.',#8,#13,#27]) then
        key:=#0;-----------------------------------------------------------------------------DelphiICQ编程站,至力于发展编程技术!http://www.DelphiICQ.com/