Ver Mensaje Individual
  #3  
Antiguo 03-03-2024
Avatar de MAXIUM
MAXIUM MAXIUM is offline
Miembro
 
Registrado: may 2005
Posts: 1.488
Reputación: 20
MAXIUM Va camino a la fama
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;
Responder Con Cita