Validando uma Data

 

Para validar uma data, utilize a seguinte função:

 

function ValidarData(const aData: string): Boolean;

begin

  try

    StrToDate(aData);

    Result := True;

  except

    Result := False;

  end;

end;

 

Para testar, use o código:

 

if not ValidarData (Edit1.Text) then

  ShowMessage('Data Inválida');

 

Data.gif

 

Luciano Pimenta®
Editor Web do Portal ClubeDelphi.NET
webeditor@clubedelphi.net
www.clubedelphi.net