Ver Mensaje Individual
  #3  
Antiguo 29-04-2010
Avatar de Lord Delfos
Lord Delfos Lord Delfos is offline
Miembro
 
Registrado: ene 2008
Ubicación: Tandil, Argentina
Posts: 558
Reputación: 17
Lord Delfos Va por buen camino
Bueno, usando la función IsValidDate:

Código Delphi [-]
uses DateUtils;

function IsValidDate(Anio, Mes, Dia): Boolean;

Así que yo haría algo así:

Código Delphi [-]
function CIEsValido(const CI: string): Boolean;
begin
  Result:= (Length(CI) = 11) and
           IsValidDate(StrToInt(Copy(CI, 0, 2)), StrToInt(Copy(CI, 2, 2)), StrToInt(Copy(CI, 4, 2))) and
           LosUltimosDigitosSonValidos;
end;

Por supuesto, habría que estar atento a cómo hace IsValidDate para manejar años con dos cifras.

Saludongos.

EDIT: Dado que siempre que se le pida al usuario ingresar números, éste va a ingresar LETRAS (el 100% de las veces ), también sería conveniente validad antes de hacer los StrToInt.
Responder Con Cita