📄 unit2_24.pas
字号:
unit Unit2_24;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
type
week=(sun,mon,tue,wed,thu,fri,sat);
{$R *.dfm}
function mday(day:week):string;
begin
case day of
sun:mday:='星期天';
mon:mday:='星期一';
tue:mday:='星期二';
wed:mday:='星期三';
thu:mday:='星期四';
fri:mday:='星期五';
sat:mday:='星期六';
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
year,month,day:word;
begin
decodedate(date,year,month,day);
edit1.Text:=format('%d年%d月%d日',[year,month,day]);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
today,yesterday,tomorrow:week;
n:integer;
begin
n:=dayofweek(now);
case n of
1: today:=sun;
2: today:=mon;
3: today:=tue;
4: today:=wed;
5: today:=thu;
6: today:=fri;
7: today:=sat;
end;
if today=low(week) then
yesterday:=high(week)
else
yesterday:=pred(today);
if today=high(week) then
tomorrow:=low(week)
else
tomorrow:=succ(today);
button1.Caption:='昨天';
button2.Caption:='今天';
button3.Caption:='明天';
case (Sender as Tbutton).Tag of
1: button1.Caption:='昨天是'+mday(yesterday);
2: button2.Caption:='今天是'+mday(today);
3: button3.Caption:='明天是'+mday(tomorrow);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Form1.Button1Click(Sender);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Form1.Button1Click(Sender);
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -