Bob said:
Thanks for the reply. However, if I use the DoEvent every 500 or 1000
iterations, I am afraid that something else may be going on, on the
system
that may take a while, and therefore slowing down my program. Do you
know
of any way for example through another thread that can do this? Or am I
going about it in the wrong direction?
Windows is inherently multitasking. That's why we "like" it, eh?
Something else is pretty much always going on. Windows is never going to
give you more than your share, based on all competing demands and balanced
by the process priority (presumably Normal?). You can boost your process
priority, but I'd strongly recommend leaving that at your user's
discretion. Adding a DoEvents every second or so isn't going to produce
much of a difference in the speed of your operation, unless of course the
*user* (remember her?) is trying to do something else. <g>
--
.NET: It's About Trust!
http://vfred.mvps.org
Karl E. Peterson said:
Bob wrote:
I was wondering if anyone has a piece of code or suggestions on how to
stop
a very large loop for example, i=1 to 10000000. If in the middle of
this
for loop, the user wants to stop everything by hitting the ESC key.
Any
suggestions on how to implement this? I can do this with the DoEvents,
but
it will slow the program down considerably. Thanks for your help.
Generally, on a loop that large, you can just do the DoEvents every 500
or
1000 or [whatever] iterations...
If i Mod 1000 = 0 Then DoEvents
Another option, although more complicated, would be to explicitly poll
the
keyboard for down keys on each loop. That's complicated in that you may
miss it if you only check every X loops. Indeed, even if X=1, you may
miss it!