When I unload a form in the middle of a loop, the form will dissapear but the loop will continue. Is there anyway to stop all the processes going on once the form is unloaded?
Printable View
When I unload a form in the middle of a loop, the form will dissapear but the loop will continue. Is there anyway to stop all the processes going on once the form is unloaded?
You can check the status of the form in each loop. It it's gone, exit the loop
VB Code:
Dim i As Long For i = 0 To 5000 Debug.Print i DoEvents [b]If Form1.Visible = False Then Exit For End If[/b] Next i
Try this:
Or set a sentinel in the loop.VB Code:
Set Me = Nothing
those are good ideas, but i'm really looking for a way, a command or something that kills it no if and buts.. i need it so it doesn't need a catch like if form1.visible = false then exit sub.. i'm thinking that this might be something that's not possible...
Did you try my way?
Why? It's not exit sub anyway, it's exit FOR (the loop)Quote:
Originally posted by jsun9
i need it so it doesn't need a catch like if form1.visible = false then exit sub.. i'm thinking that this might be something that's not possible...