-
I am having trouble with a for/next loop and a form.
When I click a command button, a for next loop pings a series of ip address specified by the user. This works fine, but while the loop is running, the form is unresponsive to mouse clicks, gets stuck behind other widows ect. until the loop finishes. Then the form returns to normal.
I added a form1.refresh to the loop, so now it redraws itself if I Move a window over it, but it still gets stuck behind other windows, and will not redraw itself on top, until the loop is finished.
Could someone please explain why this is happening?
The Loop will typically take 4 1/2 minutes to run, during this time it looks like the app is locked execpt for the progress bar moving on the form.
Thank You
-
Code:
For a = 1 to 1000
DoEvents <---Add This
'Other code
Next a
-
I may be wrong here, but to the best of my knowledge a DoEvents statement in a For Loop does nothing.
I personally only use for loops for small things.
If there's anything that'll be big or take a long time I do something like this :
Code:
i = 0
Do Until i = 1000
DoEvents
i = i + 1
'Do Something
Loop
- jamie
-
Do Events worked
Thanks for the help. This is working much better
-
It does plenderj! The For Next will 'lock' just like other loops.
-
Sorry about that, right you are.
I remember trying it before, but it never worked.
I think it was VB5 I was trying it on ....
Oh well :)