How to use ESC key to break the loop?<p>When ESC key press on 1st time, waitTime disable as graph just scroll without the delay.<br/>When ESC press the 2nd time, Error message &quot;Code execution has been interrupted&quot; &gt; [Continue], [End], [Debug]   <br/>Would like when ESC key press, it will stop the Graph display loop and back to the UserForm.<br/><br/>Do While jj &lt; ii + 1<br/>Application.OnKey &quot;{ESC}&quot;, &quot;goto BreakHandler&quot;<br/>Sheets(Graph(jj)).Select<br/>newHour = Hour(Now())<br/>newMinute = Minute(Now())<br/>newSecond = Second(Now()) + 5<br/>waitTime = TimeSerial(newHour, newMinute, newSecond)<br/>Application.Wait waitTime<br/>jj = jj + 1<br/>If jj &gt;= ii Then jj = 1<br/>Loop</p>© 2009 Microsoft Corporation. All rights reserved.Wed, 05 Aug 2009 03:14:33 Z489764f7-5b1a-4624-9b1a-b62d171177adhttp://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/489764f7-5b1a-4624-9b1a-b62d171177ad#489764f7-5b1a-4624-9b1a-b62d171177adhttp://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/489764f7-5b1a-4624-9b1a-b62d171177ad#489764f7-5b1a-4624-9b1a-b62d171177adAusJThttp://social.msdn.microsoft.com/Profile/en-US/?user=AusJTHow to use ESC key to break the loop?<p>When ESC key press on 1st time, waitTime disable as graph just scroll without the delay.<br/>When ESC press the 2nd time, Error message &quot;Code execution has been interrupted&quot; &gt; [Continue], [End], [Debug]   <br/>Would like when ESC key press, it will stop the Graph display loop and back to the UserForm.<br/><br/>Do While jj &lt; ii + 1<br/>Application.OnKey &quot;{ESC}&quot;, &quot;goto BreakHandler&quot;<br/>Sheets(Graph(jj)).Select<br/>newHour = Hour(Now())<br/>newMinute = Minute(Now())<br/>newSecond = Second(Now()) + 5<br/>waitTime = TimeSerial(newHour, newMinute, newSecond)<br/>Application.Wait waitTime<br/>jj = jj + 1<br/>If jj &gt;= ii Then jj = 1<br/>Loop</p>Fri, 03 Jul 2009 00:31:52 Z2009-07-09T01:40:59Zhttp://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/489764f7-5b1a-4624-9b1a-b62d171177ad#60314b7a-dcde-4c62-8943-7ad3a35e59e8http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/489764f7-5b1a-4624-9b1a-b62d171177ad#60314b7a-dcde-4c62-8943-7ad3a35e59e8Shasurhttp://social.msdn.microsoft.com/Profile/en-US/?user=ShasurHow to use ESC key to break the loop?<p>The solution lies in multi-threading . You can check the following thread for more:<br/><br/><a href="http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/735c8f26-2129-4b46-8c1a-aad385cab2ed">http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/735c8f26-2129-4b46-8c1a-aad385cab2ed</a></p><hr class="sig">http://www.vbadud.blogspot.comSun, 12 Jul 2009 02:25:20 Z2009-07-12T02:25:20Z