VB4 Aplication Remains In Memory After Closing

I am developing some applications in VB Version 4.0 Standard.  After compiling and installing several of these on NT or 95 platforms, I have the following problem.  When terminating the program using the "close" button in the upper right corner, I find that the program closes but remains in memory.  One of my programs is a memory hog, so this becomes a real problem.  When it is launched several times in a session, it leaves an instance running for each launch, eventually running the system out of memory.  However, when I exit the program normally using an option on my menu, that instance of the application does not remain in memory.

I have searched the knowledgebase to no avail.  Please help me!
smillerxAsked:
Who is Participating?
 
Erick37Connect With a Mentor Commented:
Perhaps one or more of your forms are not being unloaded from memory.

In your main form's Unload event:

Private Sub Form_Unload(Cancel As Integer)
    UnloadAllForms
End Sub

In a module, put this sub:

Public Sub UnloadAllForms()
    Dim Form As Form
    For Each Form In Forms
        If Form.Name <> sFormName Then
            Unload Form
            Set Form = Nothing
        End If
    Next Form
End Sub
0
 
Erick37Commented:
Correction to the sub:

Public Sub UnloadAllForms()
    Dim Form As Form
    For Each Form In Forms
        Unload Form
        Set Form = Nothing
    Next Form
End Sub
0
All Courses

From novice to tech pro — start learning today.