我是这样写的
//过滤键盘按键信息
procedure THupEdit.KeyPress(var Key: Char);
begin
  inherited KeyPress(Key);
  if FEnterTab and (Key = #13) then
  begin
    PostMessage(Handle, WM_KEYDOWN, VK_TAB, 0);
    Key := #0;
    Exit;
  end;  case FInputStyle of
  stInteger:
    if not (Key in ['0'..'9', Chr(8)]) then Key := #0;
  stFloat:
    begin
      if not (Key in ['0'..'9', '.', Chr(8)]) then Key := #0;
      if (Key = '.') and (Pos(Key, Text) > 0) then Key := #0;
    end;
  stMoney:
    begin
      if not (Key in ['0'..'9', '.', Chr(8)]) then Key := #0;
      if (Key = '.') and (Pos(Key, Text) > 0) then Key := #0;
      if (Pos('.', Text) > 0) and (Key <> Chr(8)) and
         ((Length(Text) - Pos('.', Text)) >= 2) then Key := #0;
    end;
  stBkdh:
  begin
     if pos('-',Trim(TEdit(THupedit).Text))>0 then   //此处是错误的,只 是 想告诉你个思想
       if not (Key in ['0'..'9', Chr(8)]) then Key := #0 else
     if not (Key in ['0'..'9', '-', Chr(8)]) then Key := #0;
  end;
  end;
end;