RAD Studio VCL Reference
|
Indicates whether a specified year is a leap year.
function IsLeapYear(Year: Word): Boolean;
Boolean IsLeapYear(Word Year);
Call IsLeapYear to determine whether the year specified by the Year parameter is a leap year. Year specifies the calendar year.
Use YearOf to obtain the value of Year for IsLeapYear from a TDateTime value.
C++ Examples:
/* This example requires a button and a text edit. When the user presses the button a message indicates if the year specified in the text edit is a leap year. */ bool __fastcall IsThisLeapYear(int year) { return IsLeapYear(year); } void __fastcall TForm1::Button1Click(TObject *Sender) { int year = StrToInt(Edit1->Text); if (IsThisLeapYear(year)) ShowMessage(Edit1->Text + " is a leap year."); else ShowMessage(Edit1->Text + " is not a leap year."); }
Delphi Examples:
{ This example requires a button and a text edit. When the user presses the button a message indicates if the year specified in the text edit is a leap year. } 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;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|