Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Jul 27, 1998

Closing an application

Question:
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?

Answer:
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
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date