【发布时间】:2015-05-04 22:12:21
【问题描述】:
我想在 Delphi 中制作一个倒数计时器。我用过
while(t<>0 and m<>0 and s<>0) do
但程序不接受它。我该如何解决这个问题?
【问题讨论】:
-
应该是while (t0) and (m0) and (s0) do。
-
只有一个音符;这不能作为倒数计时器的主循环(如果这是意图;我不确定,因为我希望变量
h、m、s,而不是t、@987654326 @,s,但这可能来自您的母语,我假设t是一个小时变量)。如果是这样,考虑一下当你开始数数时会发生什么,比如 10 秒。您将拥有h=0, m=0, s=10,并且仅当(h <> 0) and (m <> 0) and (s <> 0)甚至不会通过单次迭代时才尝试倒计时,因为h和m变量已经在0 中。 -
感谢您的回答,非常感谢。我使用它并且它有效,但我有一个问题,即循环非常非常快并且它显示最后时间,0:0:0。其次它没有显示 coutdown...我需要你的帮助来解决这个问题,为此我添加了程序,谢谢
-
procedure TForm1.Timer1Timer(Sender: TObject) begin while (t0) or (m0) or (s0) do begin Label1.Caption:=IntToStr(t) +':'+IntToStr(m)+':'+IntToStr(s); for i:=0 to 59 do begin ms:=ms+1;如果 s0 则开始 dec(s); endelse begin if m=0 then begin if t=0 then Label2.Caption:='it is done' else begin dec(t);米:=59; s:=60;结尾; end else begin dec(m); s:=60; Label1.Caption:=IntToStr(t)+':'+IntToStr(m)+':'+IntToStr(s) ;
-
很抱歉我无法附加该程序,我不得不删除很多内容才能将其发送给您。希望您能看到它。谢谢。
标签: delphi