Results 1 to 6 of 6

Thread: Loop keeps running after program is closed...

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 1999
    Posts
    51

    Post

    I have a loop in my program to make it pause for a certain amount of time.
    Code:
    sngTime = Timer
    Do While (Timer - sngTime) < 60
        DoEvents
    Loop
    When I exit the program it still appears to be running in the task manager. How do I tell the program to stop all processes when it's closed? Or is there a way for me to check to see if the program has been closed? Then I can exit the Sub.

    Thanks

    [This message has been edited by desquite (edited 01-28-2000).]

  2. #2
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Cleveland, Ohio
    Posts
    263

    Post

    One way to end:
    Code:
    Form_Unload(...)
    End
    End Sub
    Or inside your loop...
    Code:
    If Me.Visible = False Then End
    The second example should only be used if your form is never otherwise hidden.

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    How do you exit the program? When you do exit, do you explicitly unload all forms? If you don't do the latter, it may be the cause of your problem.

    ------------------
    Marty
    COGITO EGGO SUM
    I think; therefore I am a waffle.

  4. #4
    Hyperactive Member Juan Carlos Rey's Avatar
    Join Date
    Aug 1999
    Location
    Mendoza, Argentina
    Posts
    301

    Post

    I used to think. Now I'm just scrambled eggs!

  5. #5

    Thread Starter
    Member
    Join Date
    Jul 1999
    Posts
    51

    Post

    Here is what my unload sub looks like. It still seems to keep itself in memory though. I'm not sure what part of my program is still looping. Any ideas? Thanks.

    Code:
    Private Sub Form_Unload(Cancel As Integer)
       Timer1.Enabled = False
       Unload frmMain
       Set frmMain = Nothing
    End Sub

  6. #6

    Thread Starter
    Member
    Join Date
    Jul 1999
    Posts
    51

    Post

    Well, I got it to work. I just added an 'End' after the statements in my Unload sub.

    Thanks everyone.

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