一个进度条,走完后,间隔2秒后,自动关闭程序,有一个timer2控件,我想在进度条显示“完成”的时候,触发timer2:procedure TForm1.Timer2Timer(Sender: TObject);
begin
if  label1.Caption:='完成!'    then
close;
end;
end;
end.显示错误,[Error] Unit1.pas(59): Type of expression must be BOOLEAN
         [Error] Unit1.pas(62): '.' expected but ';' found
         [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'怎么回事?~~我设置一个变量,然后累加剩余的秒数,完成后触发timer2行么??~~~谁有好的办法,其他的控件,说说,我现在只学到timer这里~~- -谢谢了~~

解决方案 »

  1.   

    procedure TForm1.Timer2Timer(Sender: TObject); 
    begin 
      if  label1.Caption='完成!'    then 
      begin
        Timer2.Enabled:=false;
        close; 
      end; 
    end; end. 
      

  2.   

    谢谢楼上,发现问题彻底问错了不过已经解决了,其实我是想“完成”后2秒,关程序
    先timer2.Interval:=2000;
    timer2.enabled:=false;
    再if trackbar1.Position>=trackbar1.Max  then
    begin
    animate1.Active:=false;
    label1.caption:='完成!';
    timer2.enabled:=true;最后procedure TForm1.Timer2Timer(Sender: TObject);
    begin
    if trackbar1.Position>=trackbar1.Max  then
    close;
    end;
    end.谁有更简洁的办法么~~~(楼上我会给你分的,怪我。。一着急忘了~~)
      

  3.   

    2楼的大哥,为啥把timer2关了(Timer2.Enabled:=false;) 就行了呢~~~??我把我3楼的最后,if trackbar1.Position>=trackbar1.Max  then 换成if label1.caption:='完成!'   then为啥就不行了。知道的说下,谢谢啦~~ 
      

  4.   

    if label1.caption:='完成!'  then语法错误了 :=   是赋值语句
    a:=3  就表示让a的值是3
    if label1.caption = '完成!'  then
    才对,基本功底不扎实……
      

  5.   

    if  label1.Caption:='完成!'    then 

    标示符错误
    end; 
    end; 
    多了一个end;
    你的两个报错是因为这两个原因
      

  6.   


    if trackbar1.Position>=trackbar1.Max  then 
    begin 
    animate1.Active:=false; 
    label1.caption:='完成!'; 
    sleep(2000);
    close;
    end;
      

  7.   

    判断事务处理完成后直接用Application.terminal 不就行了吗?
      

  8.   

    procedure TForm1.Timer2Timer(Sender: TObject); 
    begin 
    if  label1.Caption='完成!'    then 
    close; 
    end; end. 
      

  9.   

    关闭程序用 application.Terminate;
    close只是关闭当前窗体。
      

  10.   

    if  label1.Caption:='完成!'    then 
      

  11.   

    "最后procedure TForm1.Timer2Timer(Sender: TObject); 
    begin 
    if trackbar1.Position>=trackbar1.Max  then 
    close; 
    end; 
    end. 
    "
    这里不需要判断 if trackbar1.Position>=trackbar1.Max  了
    直接
    begin
      Application.Terminate;
    end
    就可以了,这样可以简洁一点
      

  12.   

    同意直接Application.Terminate; Application也是窗口,它关闭了所有窗口也就关闭并且进程结束