Ver Mensaje Individual
  #2  
Antiguo 29-04-2010
Ledian_Fdez Ledian_Fdez is offline
Miembro
 
Registrado: jun 2006
Ubicación: Ciudad Habana, Cuba
Posts: 242
Reputación: 18
Ledian_Fdez Va por buen camino
Post Código

Código Delphi [-]
Function ValidaCI(CI : String) : Boolean;
var
 flat : Boolean;
 fecha : TDateTime;
begin
 flat := True;
 if (Length(CI) <> 11) then
   begin
    flat := False;
    Application.MessageBox('No. Carnet de Identidad incompleto.' + #13 + 'Rectifique por favor.','SAF', MB_ICONERROR);
   end
 else if StrToInt(Copy(CI,3,2)) > 12 then
   begin
    flat := False;
    Application.MessageBox('Error en el mes del Carnet de Identidad.' + #13 + 'Rectifique por favor.','SAF', MB_ICONERROR);
   end
 else
   begin
    try
     fecha := StrToDate(Copy(CI,5,2)+ '/' + Copy(CI,3,2) + '/' + Copy(CI,1,2));
    except
     flat := False;
     Application.MessageBox('La fecha de nacimiento no es válida.' + #13 + 'Rectifique por favor.','SAF', MB_ICONERROR);
    end;
   end;
 Result := flat;
end;
Responder Con Cita