问:delphi中我想实现时间倒计时!咋写程序?谢谢
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
3个回答
2016-05-22
展开全部
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Timer1: TTimer;
Label1: TLabel;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
var
t, nt:Tdatetime;
i:integer;
xs,m,s:string;
{$R *.DFM}
procedure TForm2.Timer1Timer(Sender: TObject);
begin
if i > 0 then i:=i-1 else i:=1000;
nt:=now();
xs :=formatdatetime('hh:mm:ss',nt-t);
if xs ='00:10:00' then Timer1.Enabled:=false; //设定时间10分钟
m:= inttostr(9 - strtoint(copy(xs,4,2)));
if length(m)=1 then m :='0'+m;
s:=inttostr(59 - strtoint(copy(xs,7,2)));
if length(s)=1 then s :='0'+s;
label1.Caption:='00:'+m+':'+s+':'+inttostr(i);
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
Timer1.Interval:=1;
if Timer1.Enabled then Timer1.Enabled:=false
else Timer1.Enabled:=true;
t:=now();
end;
end.
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Timer1: TTimer;
Label1: TLabel;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
var
t, nt:Tdatetime;
i:integer;
xs,m,s:string;
{$R *.DFM}
procedure TForm2.Timer1Timer(Sender: TObject);
begin
if i > 0 then i:=i-1 else i:=1000;
nt:=now();
xs :=formatdatetime('hh:mm:ss',nt-t);
if xs ='00:10:00' then Timer1.Enabled:=false; //设定时间10分钟
m:= inttostr(9 - strtoint(copy(xs,4,2)));
if length(m)=1 then m :='0'+m;
s:=inttostr(59 - strtoint(copy(xs,7,2)));
if length(s)=1 then s :='0'+s;
label1.Caption:='00:'+m+':'+s+':'+inttostr(i);
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
Timer1.Interval:=1;
if Timer1.Enabled then Timer1.Enabled:=false
else Timer1.Enabled:=true;
t:=now();
end;
end.
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
网易云信
2023-12-06 广告
2023-12-06 广告
很高兴能回答您的问题。以下是一段针对“一对一消息组件”的描述,字数在200字左右:该组件支持用户之间的私密交流,让沟通更加直接和高效。通过它,您可以向特定对象发送消息,并实时查看消息状态,包括对方是否已读或未读。同时,该组件还支持富文本消息...
点击进入详情页
本回答由网易云信提供
展开全部
gettickcount
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询