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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Erick37Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.