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;
begin
if not (Char(Msg.CharCode) in ['0'..'9', #8] then
begin
Msg.CharCode:=0;
if Assigned(fInputError) then
fInputError(Self);
end;
end;
因为and的原因。或者改为if (not (Char (Msg.CharCode) in ['0'..'9'])) and (not (Msg.charCode=8) ) then试试
begin
if not (key in['0'..'9',#8]) then
key:=#0;
end;
这个是在EDIT中增加一个KEYPRESS属性下写的代码