Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Application Shutdown???

0 views
Skip to first unread message

Kevin D. Drucker

unread,
Sep 6, 1995, 3:00:00 AM9/6/95
to
I have a VB app that I am working on. When I run the application from
within VB and close the app via the system menu CLOSE command (little
box in upper left hand of window) the app does not shutdown completely.
However, I added an exit command to my File menu and within the EXIT
method I placed an END command. This forced the software to completely
exit when I execute the EXIT from my File menu.

Am I missing something?? Do I have to manually unload every form or
something like that??

I was under the impression that VB called the EXIT method when CLOSE is
clicked (alt-f4)?????????

Please mail and post suggestions.

+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Kevin D. Drucker | e-mail: dru...@cellerity.com (preferred) |
| Electronics Desn Engr | kddr...@amp.com (alternate) |
| Connectware, Inc. | voice: (215) 233-4674 fax: (215) 233-891 |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+

Greg Dainard

unread,
Sep 7, 1995, 3:00:00 AM9/7/95
to
In article <42k9s1$6...@vgreen.cellerity.com>, dru...@cellerity.com
says...
<snip>

>Am I missing something?? Do I have to manually unload every form or
>something like that??

Kevin, there is no guarantee that an app will have a File/Exit. Every
VB form has an Unload Event though. I think this works and gets
called when the user does the System Close thing:

Form_Unload(Cancel As Integer)
End
End Sub

This isn't completely correct; you should probably test the Cancel
variable (comes from Form_QueryUnload, I think).
--
Greg Dainard e-mail: ge...@phoenix.net
Systems Analyst WWW: http://www.phoenix.net/~getj


Don Clark

unread,
Sep 9, 1995, 3:00:00 AM9/9/95
to
In article <cstuart.38...@metronet.com>,

cst...@metronet.com (Chuck Stuart) wrote:
>>I have a VB app that I am working on. When I run the application from
>>within VB and close the app via the system menu CLOSE command (little
>>box in upper left hand of window) the app does not shutdown completely.
>>However, I added an exit command to my File menu and within the EXIT
>>method I placed an END command. This forced the software to completely
>>exit when I execute the EXIT from my File menu.
>
>>Am I missing something?? Do I have to manually unload every form or
>>something like that??
>
>>I was under the impression that VB called the EXIT method when CLOSE is
>>clicked (alt-f4)?????????
>
>Put an END statement in the Unload event.

>
>
>>+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
>>| Kevin D. Drucker | e-mail: dru...@cellerity.com (preferred) |
>>| Electronics Desn Engr | kddr...@amp.com (alternate) |
>>| Connectware, Inc. | voice: (215) 233-4674 fax: (215) 233-891 |
>>+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
>
>
>
>------------------------------------------------------------------------
>Chuck Stuart - Mesquite TX USA
>VBTrace 2.00 is a runtime Procedure Trace, XRef,
>Debug, Profiler and much more. Shareware $49.
>http://www.apexsc.com/vb/ftp/coop/cstuart
>ftp.apexsc.com/pub/cgvb/coop/cstuart
>------------------------------------------------------------------------
Try this bit of code Kevin, I think it will solve your problem.

Sub Form_Unload (Cancel As Integer)
' This code explicitly causes all application forms to unload when the
' user terminates the program. This keeps the application from leaving a
' form loaded in memory, which leaves the VB parent window open to the
' Task List.

Dim I

For I = 0 To Forms.Count - 1
Unload Forms(I)
Next I

End

End Sub

Don Clark

Andrew Cheshire

unread,
Sep 9, 1995, 3:00:00 AM9/9/95
to
In article: <42r4hp$f...@shiva.usa.net> dmc...@usa.net (Don
Clark) writes:
>
> Try this bit of code Kevin, I think it will solve your
> problem.
>
> Sub Form_Unload (Cancel As Integer)
> ' This code explicitly causes all application forms to
> unload when the
> ' user terminates the program. This keeps the
> application from leaving a
> ' form loaded in memory, which leaves the VB parent
> window open to the
> ' Task List.
>
> Dim I
>
> For I = 0 To Forms.Count - 1
> Unload Forms(I)
> Next I
>
> End
>
> End Sub


Sorry, this doesn't work, you get a "Subscript out of range"
error. Here is some tested code :-


Sub Form_Unload (Cancel As Integer)

Dim i As Integer
Dim f As Form

muloop:
For i = 0 To Forms.Count - 1
Set f = Forms(i)
If Not f Is Me Then
Unload f
GoTo muloop
End If
Next i

End Sub

----------------------------------------------
Andrew Cheshire an...@axiomati.demon.co.uk
Axiomatic Software CIS: 100273,154
"i forgive you molesworth for those uncouth words"


Chuck Stuart

unread,
Sep 10, 1995, 3:00:00 AM9/10/95
to
>> Sub Form_Unload (Cancel As Integer)
>> Dim I
>>
>> For I = 0 To Forms.Count - 1
>> Unload Forms(I)
>> Next I
>>
>> End
>>
>> End Sub


>Sorry, this doesn't work, you get a "Subscript out of range"
>error. Here is some tested code :-


>Sub Form_Unload (Cancel As Integer)

> Dim i As Integer
> Dim f As Form

>muloop:
> For i = 0 To Forms.Count - 1
> Set f = Forms(i)
> If Not f Is Me Then
> Unload f
> GoTo muloop
> End If
> Next i

>End Sub

The reason you get subscript error is because when you unload a form, the
forms.Count is reduced from what the loop is initialized to do. To elimate
this problem, simply loop backwards.
For I = Forms.Count - 1 to 0

Jens Balchen jr.

unread,
Sep 11, 1995, 3:00:00 AM9/11/95
to
In article <893295...@axiomati.demon.co.uk>, Andrew Cheshire wrote:

>
> Sub Form_Unload (Cancel As Integer)
>
> Dim i As Integer
> Dim f As Form
>
> muloop:
> For i = 0 To Forms.Count - 1
> Set f = Forms(i)
> If Not f Is Me Then
> Unload f
> GoTo muloop
> End If
> Next i
>
> End Sub

A better solution is:

For i = Forms.Count - 1 To 0 Step - 1
If Not Forms(i) Is Me Then Unload Forms(i)
Next

The reverse count does the trick.

Jens
--
* Everything I said are the opinions of someone else. *
* I just cut-and-pasted. *

Jens Balchen jr.
bal...@oslonett.no
P.O.Box 6052
N-4602 Kristiansand

0 new messages