while Readflag<>'>' do
     begin
        CanExitTimer.Enabled:=true;
        Application.ProcessMessages;
        if CanExitTime>20 then
          begin
             Main.Close;
          end;
     end;
小弟如上写,但当CanExitTime>20后程序就是不关闭,请指教,谢谢,祝各位朋友新年快乐

解决方案 »

  1.   

    加一个 break;  就可以了while Readflag<>'>' do
         begin
            CanExitTimer.Enabled:=true;
            Application.ProcessMessages;
            if CanExitTime>20 then
              begin
                 Break;  //退出循环
              end;
         end;
      

  2.   

    因代码有具体功能要求,不能用BREAK,请赐教,谢谢
      

  3.   

    while Readflag<>'>' do
         begin
            CanExitTimer.Enabled:=true;
            Application.ProcessMessages;
            if CanExitTime>20 then
              begin
                 Application.terminate; //
              end;
         end;
      

  4.   

    :qybao(阿宝)  的比较COOL   直接结束程序了.
    小弟不才,只知道:  continue; 结束本次循环.
    break;  跳出循环
    C++中用Goto也可,但不推荐
      

  5.   

    汗qybao(阿宝)的Application.terminate一个先……
    正常的退出循环用break,强烈不推荐Application.terminate……
      

  6.   


           Breakl;或 Exit;
      

  7.   

    你是要退出程序还是退出本次循环?不能用break的话可以设个bool变量
    isexit:=false;
    while (Readflag<>'>') and (not isexit) do
         begin
            CanExitTimer.Enabled:=true;
            Application.ProcessMessages;
            if CanExitTime>20 then
              begin
                 isexit:=true;
              end;
         end;
      

  8.   

    C++中用Goto也可,但不推荐==================================
    delphi里也有GOTO阿……
    因代码有具体功能要求,不能用BREAK,请赐教,谢谢
    ===================================================-_-! 想不明白……
      

  9.   

    while (Readflag<>'>') and (CanExitTime<=20 ) do
      

  10.   

    完全同意楼上的
    为什么不能用Break
    看不出理由的说
      

  11.   

    how do you unserstand this [但当CanExitTime>20后程序就是不关闭]
    program close that means application terminate
      

  12.   

    谢谢各位前辈的指教,偶用如下办法关闭程序的,
            if CanExitTime>20 then
              begin
                 Application.terminate;
                 exit;
              end;
    但为何 hellolongbin(一个人)兄说的 “强烈不推荐Application.terminate……”,有何不妥吗?
    谢谢
      
     
      

  13.   

    如果只是结束循环而不退出程序,我上面的方法就可以;如果你要在循环结束后结束程序,Application.terminate也不是不可以,唉,我想给你举个类似的浅显的例子,一时想不出来,算了,想到再说吧
      

  14.   

    另外,Application.terminate了就不用再exit了
      

  15.   

    if you do not use thread or create any object by yourself or operate a file, application.terminate is a safe procedure, has no any problem, or you should stop thread or destroy your object or close file first. but in normal, system will auto do this or you can use application.ProcessMessages to post the window message queue.