IsLeapYear (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example requires a button and a text edit. When you press the button, a message indicates whether the year specified in the text edit is a leap year.

Code

function IsThisLeapYear(year : Word): Boolean;
begin
  Result := SysUtils.IsLeapYear(year);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  year : integer;
begin
  year := StrToInt(Edit1.Text);
  if (IsThisLeapYear(year)) then
    ShowMessage(Edit1.Text + ' is a leap year.')
  else
    ShowMessage(Edit1.Text + ' is not a leap year.');
end;

Uses

Personal tools
Assistance