procedure TNumEdit.WmChar(var Msg: TWmChar);
begin
   if not (Char(Msg.CharCode) in ['0'..'9', #8] then
   begin
      Msg.CharCode:=0;
      if Assigned(fInputError) then
         fInputError(Self);
   end;
end;

解决方案 »

  1.   

    if not (Char (Msg.CharCode) in ['0'..'9']) and not (Msg.charCode=8) then改为if not (Char (Msg.CharCode) in ['0'..'9',#8] then
    因为and的原因。或者改为if (not (Char (Msg.CharCode) in ['0'..'9'])) and (not (Msg.charCode=8) ) then试试
      

  2.   

    说清楚点,你这好像是做了个组件。你的构造函数好象有问题,我觉得这个东东没法倒入delphi后托拽到form上吧!
      

  3.   

    procedure tform1.editkeypress(sender:tobject;var key:char);
    begin
    if not (key in['0'..'9',#8]) then 
     key:=#0;
    end;
    这个是在EDIT中增加一个KEYPRESS属性下写的代码