不能让其在.text中输入汉字及字母~只能输入4位的数字~~
这个程序要如何编写呢~~~
用什么方法限制其输入汉字及字母啊~请指教谢谢~~

解决方案 »

  1.   

    KeyPress中写if not (Key in [0..9, #8]) and (Length(Edit1.Text) >= 4) then Key := #0试一下
      

  2.   

    SetWindowLong(Edit1.Handle,  GWL_STYLE,  
                                       GetWindowLong(Edit1.Handle,  GWL_STYLE)  or
                                       ES_NUMBER);
      

  3.   

    if not (key in ['0'..'9',#8,#13]) and (Length(Edit1.Text) >= 4) then
     begin
       key := #0;
     end;
      

  4.   

    还有一种限制长度方法就是把 Edit1 的 Maxlength属性设置为4
      

  5.   

    把一楼的改一下
    if not (Key in ['0'..'9',#8]) then Key := #0;再加上yalaso(你啥时候来的?) 的方法,测试通过。
      

  6.   

    function  CheckInt(Data : String) : Boolean;
    var
      code : Integer;
      r    :Integer;
    begin
      Val(Data,r,code);
      if code = 0 then
        Result := True
      else
        Result := False;
    end;
      

  7.   

    没说清楚应该是加上yalaso(你啥时候来的?) 的第二种方法。