Breaking For Loops

Questions regarding syntax

Breaking For Loops

Postby PMan » Sat Jan 08, 2011 11:54 am

Hi,

I'm looking for a possibility to break a For Loop with a Cancel-CommandButtom. While running the For Loop the event cbCancel_OnEvent() of the buttom is still sleeping and nothing appears, when I push the commandbuttom.

What code must be written in the for loop, to break it with a buttom?

/PMan
PMan
 
Posts: 145
Joined: Sat Jul 03, 2010 12:31 pm
Location: Switzerland

Re: Breaking For Loops

Postby Henning » Sat Jan 08, 2011 12:26 pm

What you need is a DoEvents inside the For/Next loop.
A loop will be so busy, that other code outside the loop can't execute.
DoEvents will make a short sleep in the loop so events will have a possibility to trigger.

/Henning
Henning
 
Posts: 262
Joined: Mon Feb 09, 2009 12:03 am
Location: Sweden


Return to Coding Questions

cron