-
I have some rather long Do...Loop's in my program.....I have put the DoEvents command inside some of the longer loops, and my program is starting faster and there are no visual screen problems with repainting now.
My question is:
Is there any negative effect of the DoEvents command or using too many DoEvents commands??
Please advise.
Thanks!!!
-
The only negative effect there is is that your program runs slower, because it gives the OS time to repaint the screen and do whetever it needs to do.
You must be careful though, it is possible to close a form that's running a loop with doevents... possibly crashing the program.
You can get around that by setting some variable when the loop runs and check that var when the user wants to close the form, and do not allow it to unload. Or stop the loop and then unload.
Gerco.
-
I see.
The reason I added the DoEvents is because when the program was in the loop, which is a SUB in a MODULE, the screen was showing large white blocks for some of the controls....and it was taking a long time after issuing the command.
After adding the: openforms = DoEvents
the program started with lighting speed and I had no white spaces.
Is this practice ok??
P.S. Thanks for the info.
-
you can also test the actual DOEvents in the loop
if DoEvents = 0 then exit loop
-
Sure you can do that... the white blocks are because the OS doesn';t have time to paint your program's window.
To allow the OS some time, use DoEvents.
Gerco.
-
Thanks again!
Your help is extremely appreciated!!!!