unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
procedure Button1Click(Sender: TObject);
private
{ 该类型的成员只能在声明类中被访问 }
public
{ 该类型的成员可以被程序中的任何地方的代码访问 }
{变量声明}
Mouth,day,Year:Integer;
{过程}
procedure SetValue(y:Integer);
{函数}
function LeapYear(y:Integer):String;
Protected
{ 该类型的成员只能在声明类以及声明类的派生类中被访问 }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{过程}
procedure TForm1.SetValue(y:Integer);
begin
Year := y;
end;
{函数}
function TForm1.LeapYear(y:Integer):String;
begin
if ( y=1 ) then
LeapYear := '1111'
else
LeapYear := '0000'
end;
{事件执行}
procedure TForm1.Button1Click(Sender: TObject);
begin
Year:=1;
Edit1.Text := LeapYear(Year);
SetValue(2000);
Edit2.Text := Year.ToString();
end;
end.