我今天有病!!!!!!!!!!!

Maxdell 2002-12-14 10:05:36
为了做一个计时器(格式为 00:00:00),我编程如下:
var
Form1: TForm1;
secend:integer;
min:integer;
hour:integer;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
secend:=secend+1;
if (min<59)then
begin
if (secend>59)then
begin
min:=min+1;
secend:=0;
end;
end
else
begin
hour:=hour+1;
min:=0;
end;
if (min>9)then
begin
if (secend>9)then
label1.Caption:=inttostr(hour)+' : '+inttostr(min)+' : '+inttostr(secend)
else
label1.Caption:=inttostr(hour)+' : '+inttostr(min)+' : '+'0'+inttostr(secend);
end
else
begin
if (secend>9)then
label1.Caption:=inttostr(hour)+' : '+'0'+inttostr(min)+' : '+inttostr(secend)
else
label1.Caption:=inttostr(hour)+' : '+'0'+inttostr(min)+' : '+'0'+inttostr(secend);
end;

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
secend:=0;
min:=0;
hour:=0;
end;

end.

我今天有病!!!
...全文
20 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
EpopeeLei 2002-12-14
  • 打赏
  • 举报
回复
var
Form1: TForm1;
counter:Integer;
implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
var temp:Integer;
s:String;
begin
counter:=counter+1;
temp:=counter div 3600;
s:=Format('%.2d',[temp]);
temp:=(counter mod 3600) div 60;
s:=s+':'+Format('%.2d',[temp]);
temp:=counter mod 60;
s:=s+':'+Format('%.2d',[temp]);
Label1.Caption:=s;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
counter:=130;
end;

end.

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧