在Edit的OnChange事件中删除Edit的Text中非数字字符

解决方案 »

  1.   

    在Edit的OnChange事件中删除Edit的Text中非数字字符
      

  2.   

    在Edit1的OnKeyPress事件中
    if Not (Key in ['0'..'9']) then
      Key:=#0;
      

  3.   

    首先你可以用,MaskEdit,
    也可以在TEdit 的OnkeyPress中写代码

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

  4.   

    在KeyPress事件中
    procedure KeyPress(Sender: TObject; var Key: Char);
    begin
      inherited;
    if (not (key in [chr(48)..chr(57)])) and (key <> #13) and (key<>#8) then
    key := #0;
    end;
      

  5.   

    用一个EDIT,来作带小数点的数字float型(99.999)输入,代码应该如何?
    ----------
    数据表中有一个列为FLOAT型,是数量。
    列名       类型    含义
    sale_sl   float   数量想在窗体上放一个EDIT,让用户只能在上面输入带小数点的数字。
    最大为 99.999我现在用的是KeyPress事件。内容为  
    ==============
    if not (key in ['0'..'9','.',#13]) then  key:=#0;
    if (key = '.') and (Pos('.', Edit1.Text) > 0) then   key := #0;
      

  6.   

    在楼上的代码中加一键#8
    if not (key in ['0'..'9','.',#13,#8]) then  key:=#0;最好是输入完后检查.