Re: do pop up boxes stop all events?



<tadamsmar@xxxxxxxxx> wrote in message news:1190161756.664421.29960@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

See above you said: "only the code in the Sub
that displayed the MsgBox will be halted"

Have a look at the response I've just posted (twenty minutes or so before this one).

but the public Sub (a different Sub) called from
main is also halted.

I meant that code in /events/ will still work while the MsgBox is displayed, and the events will still continue to be generated, so any code they contain will still be actioned. The code in the Sub that caused the MsgBox to appear will stop, exactly as I've said, but other code in other events will continue to work (at least other code that is not itself waiting for termination of the code that caused the MsgBox to appear).

In your specific case you appear to be running a tight loop in a block of code in a sub (Main?) and the code in that sub appears to contain some DoEvents (so that the user can still react with your Forms). That is not really the way to tackle most jobs.

When the "tight loop code" in your Main sub calls DoEvents it causes your app to go away and perform any outstanding events, and the code in your sub (the tight loop code in Main) will not move onto the next line of code in that Sub until all events have been actioned. However, one of the events it has "gone away to look after" is the event that occurred when the user clicked the button that caused the MsgBox or the CommonDialog to display, and since code in that event is stopped (as I said it would be) until the user dismisses the MsgBox or the Dialog then the "event" which your DoEvents allowed to happen has not been completed, therefore the next line of code in your Main sub loop (the line of code following the DoEvents) will not be actioned until the user dismisses the MsgbBox and allows the event to complete. In other words, the DoEvents in your tight loop code in Sub Main (if that's where you've got it) is blocking the rest of that Sub code from executing until the events have been fully dealt with. That's where your problem lies, and if you look at the response I posted about twenty minutes ago you'll see how it can easily be done without your "tight code in a loop" method. The method I've suggested in my previous response should solve your problem.

Mike




.


Loading