Closing an application

Closing an application

When I press the Close button on my app’s main form, the program appears to end. When I look at the Windows task list, however, my app is still there. How can I correct this so that when I click the Close button the program completely closes down?

You’ve probably forgotten to unload one or more of your app’s forms. Try adding the following code to your main form’s Unload event:

   Private Sub Form_Unload(Cancel As Integer)       Dim frm As Form       For Each frm In Forms           Unload frm       Next   End Sub

The above code won’t work in VB3, but you can do this instead:

   Sub Form_Unload(Cancel As Integer)       Dim I As Integer       For I = Forms.Count - 1 To 0 Step -1           Unload Forms(I)       Next   End Sub
See also - an AI reverse image search platform

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist