De a poco agarrando gusto por ChatGPT. Usando Enum, evitas errores.
Código Delphi
[-]type
TTipoEntrada = (teSoloLetras, teSoloNumerosEnteros, teSoloNumerosDecimales, teLetrasYNumeros);
function TFunciones.ValidarEntrada(Key: Char; Tipo: TTipoEntrada): Char;
begin
case Tipo of
teSoloLetras:
if not (Key in ['a'..'z', 'A'..'Z', ' ', #7, #8, #13]) then Result := #0
else Result := Key;
teSoloNumerosEnteros:
if not (Key in [#8, '0'..'9', '+', '-', #13]) then Result := #0
else Result := Key;
teSoloNumerosDecimales:
if not (Key in ['0'..'9', '.', #8]) then Result := #0
else Result := Key;
teLetrasYNumeros:
if not (Key in ['0'..'9', '.', 'a'..'z', 'A'..'Z', ' ', #7, #8]) then Result := #0
else Result := Key;
end;
end;