Results 1 to 5 of 5

Thread: App stays in processes once closed

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Posts
    250

    App stays in processes once closed

    How is it when I close out of my application that it stays running in my processes?

  2. #2
    Addicted Member sigid's Avatar
    Join Date
    May 2006
    Location
    Massachusetts, USA
    Posts
    182

    Re: App stays in processes once closed

    Does your app Dim F as form and then F.Show?
    When the main app closes, this DIMmed form does not close automatically - it is up to you to close it manually and then set it to nothing.

    An easy way of doing this is to place this in the Form_Unload event of the main form of the program:

    VB Code:
    1. Dim x As Long
    2.     '---------------------------------------------------------------------
    3.     On Error Resume Next
    4.     '---------------------------------------------------------------------
    5.     For x = Forms.Count - 1 To 0 Step -1
    6.         If Not Forms(x) Is Me Then
    7.             Unload Forms(x)
    8.             Set Forms(x) = Nothing
    9.         End If
    10.     Next
    11.     On Error GoTo 0

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2006
    Posts
    250

    Re: App stays in processes once closed

    If a user X's out, would that work then too?

  4. #4
    Addicted Member sigid's Avatar
    Join Date
    May 2006
    Location
    Massachusetts, USA
    Posts
    182

    Re: App stays in processes once closed

    Yep - anything that causes the main form to UNLOAD will cause that code to execute. Of course, I am ASSUMING that the "orphaned" form is the cause of your problem, and I may be wrong...

  5. #5
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: App stays in processes once closed

    in form unload ..

    VB Code:
    1. Do Until Forms.Count = 1
    2.     Unload Forms(Forms.Count - 1)
    3. Loop
    4.  
    5. Or ..
    6.  
    7. Dim Form
    8. For Each Form In Forms
    9.     Unload (Form)
    10. Next Form

    in form terminate..
    VB Code:
    1. unload me

    make sure you stop any timers also ..and close any other objects that maybe open ..

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