Ver Mensaje Individual
  #5  
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, en ese caso estás jodido, porque que yo sepa no hay una función de Delphi que haga eso.

Se me ocurre que se podría hacer algo así:

Código Delphi [-]
procedure ValidarFecha(Anio, Mes, Dia: Integer; out Error: Integer);
begin
  if Anio <= 0 then //Ó Anio < 0 si es año con dos dígitos.
    Error:= 1
  else if not (Mes in [1..12]) then
    Error:= 2
  else if (Dia > MonthDays[IsLeapYear(Anio), Mes]) then
    Error:= 3
  else
    Error:= 0;
end;

var Error: Integer;

begin
  ValidarFecha(2010, 2, 29, Error);
  case Error of
     0: ShowMessage('La fecha es válida.');
     1: ShowMessage('Año incorrecto.');
     2: ShowMessage('Mes incorrecto.');
     3: ShowMessage('Día incorrecto.');
  end;
end;
Responder Con Cita