请问如何实现

解决方案 »

  1.   

    edt1KeyPress事件中增加
    begin
      if not ((key >= '0') and (key <= '9')) then
      if (key <> #8) then
          key := #0;
    end;
      

  2.   

    楼上的njbudong(最爱戴妃) :
    你这样做可以达到目的,,但又带来新的问题如果用户用使用删除键怎么办
    if not ((key >= '0') and (key <= '9')) then////
    if (key <> #8) then//#8是哪个键的代码?先杳一下。。
      

  3.   

    edt1KeyPress事件中增加
    begin
      if not ( key in ['0'..'9',#8] )then
        key := #0;
    end;
      

  4.   

    begin
      if not ( key in ['0'..'9',#8] )then
        key := #0;
    end; 同意,这种方法是如何来判断 是否输入的是数字
      

  5.   

    SetWindowLong 
    添加 ES_NUMBER 的风格
      

  6.   

    为什么不用MaskEdit,最简单了,一行代码也不用写
      

  7.   

    ----------------------------------
    为什么不用MaskEdit,最简单了,一行代码也不用写
    ----------------------------------------------
    UPUPUPUPUPUPUPU.
      

  8.   

    用函数判断呀,
    function IsDigit(Str:String):boolean;
    begin
      result:=true;
      try
        StrToInt(Str);
      except
        result:=false;
      end;
    end;
    if IsDigit(Edit1.Text) then
    ...
    else
    ...
      

  9.   

    帮你搞定:
    在edit的onkeypress中
    if ((key<'0') or (key>'9')) and (key<>'.') and (key<>#13) and (key<>#8) then
    begin
      application('','');
      abort;
    end;
    应该很全了。
      

  10.   

    同意楼上,#13是回车,8是BACKSPACE,‘.’是小数点。8 比较重要,#13和‘.’好象就可以免了。
      

  11.   

    我认为flymoon(花儿月)的方法不错!