Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Kill program FAST Help

Posted on 2002-03-19
Medium Priority
Last Modified: 2010-05-02
My program has 3 forms, when the first one triggers the secound form to load, I hide the first.  The
problem is, if the user closes that secound or third  form, then the first/Second one still exists but is hidden so you have to go into the task manager to close it.  
Need help fast for this question please
Question by:bojman
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 39

Expert Comment

ID: 6881958
in a bas module add the following sub

public sub CloseApplication()
for intCnt =forms.count to 1 step -1
   unload forms(intCnt)
next intCnt
end sub

use CloseApplication whenever you want to close all

Accepted Solution

Moogy earned 900 total points
ID: 6881963
It's the job of the programmer to keep track of all objects and clean things up, so you'll need to write some code to regulate this.

Using the End statement is an easy way to shut things down, but it can be dangerous and doesn't always clean things up.  I recommend against it.

What I recommend is creating a shutdown procedure that cycles through the loaded forms and unloads all of them.  you can execute this feature when the user shuts down a form, or executes an exit.

An example:

Do While Forms.Count > 0
 Unload Forms(0)

You can also walk the forms collection when another form is unloaded or hidden and find out if all of the forms are hidden - if so, then shut down.  For example:

Dim bVisible as boolean
Dim iLoop as Integer

For iLoop = 0 to Forms.count - 1
 if forms(iLoop).Visible then
   exit for

if bVisible = false then
 ' Unload everything...

I hope this helps!

LVL 39

Expert Comment

ID: 6881964
sorry use this
public sub CloseApplication()
for intCnt =forms.count-1 to 0 step -1
  unload forms(intCnt)
next intCnt
end sub

LVL 53

Expert Comment

by:Ryan Chong
ID: 6881973
LVL 53

Expert Comment

by:Ryan Chong
ID: 6881975
Sorry as didn't see Moogy already post it.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question