Results 1 to 6 of 6

Thread: stopping all code once form is unloaded?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    525

    Question stopping all code once form is unloaded?

    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?

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    You can check the status of the form in each loop. It it's gone, exit the loop
    VB Code:
    1. Dim i As Long
    2.  
    3. For i = 0 To 5000
    4.     Debug.Print i
    5.     DoEvents
    6.     [b]If Form1.Visible = False Then
    7.         Exit For
    8.     End If[/b]
    9. Next i

  3. #3
    Try this:
    VB Code:
    1. Set Me = Nothing
    Or set a sentinel in the loop.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    525
    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...

  5. #5
    Did you try my way?

  6. #6
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    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...
    Why? It's not exit sub anyway, it's exit FOR (the loop)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width