Solved

Kill program FAST Help

Posted on 2002-03-19
5
165 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 50

Expert Comment

by:Ryan Chong
ID: 6881973
End
0
 
LVL 50

Expert Comment

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

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 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…

832 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