?? dates1form.pas
字號:
unit Dates1Form;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TDate = class
Month, Day, Year: Integer;
procedure SetValue (m, d, y: Integer);
function LeapYear: Boolean;
end;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
EditYear: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TDate.SetValue (m, d, y: Integer);
begin
Month := m;
Day := d;
Year := y;
end;
function TDate.LeapYear: Boolean;
begin
// call IsLeapYear in SysUtils.pas
Result := IsLeapYear (Year);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
ADay: TDate;
begin
// create an object
ADay := TDate.Create;
try
// use the object
ADay.SetValue (1, 1, StrToInt (EditYear.Text));
if ADay.LeapYear then
ShowMessage ('Leap year: ' + IntToStr (ADay.Year));
finally
// destroy the object
ADay.Free;
end;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -