Solved

Kill program FAST Help

Posted on 2002-03-19
5
164 Views
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
0
Comment
Question by:bojman
  • 2
  • 2
5 Comments
 
LVL 39

Expert Comment

by:appari
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
0
 
LVL 1

Accepted Solution

by:
Moogy earned 300 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)
Loop

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
   bVisible=true
   exit for
 Endif
Next

if bVisible = false then
 ' Unload everything...
endif

I hope this helps!




0
 
LVL 39

Expert Comment

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

0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6881973
End
0
 
LVL 49

Expert Comment

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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now