I don't know of a practical way to make a program smart enough to know when
it shouldn't be doing what you told it to. You can, I think, have it check
the time at the beginning of a loop and then if it spends more than <n
seconds inside the loop it can stop and display an abend message. But would
you want to do that with every loop you create in an event routine?
There is another way around it: A human can at some point get suspicious
and hit <Ctrl-Break (or is it <Ctrl-SysRq? I always get them confused),
which will cause the routine to stop and allow you to look at the debugger to
figure out what's going on; at that point you can decide whether to stop the
run, allow it to continue or fix the logic and let it go on from there.
That's helpful only when the user is also the author, of course, or at least
a VBA writer himself; if you're handing this routine to be used by others it
doesn't solve your problem.
--- "Raj" wrote:
In events programming, not using Application.enableevents = True and
False code comibination may result in an endless loop.
Is there any way to detect whether an endless loop has been
trigerred? Is there any indication in the VB editor to indicate that
there is currently no endless loop running?
I am asking this as it may take quite some time before the system runs
out of resources because of the endless loop.