From: Bee on
Down in the bowels of my VB6 app I need to ask the user to do something or
"die".
That is the way it is and I cannot change this structure.
I have seen applications that use >>> End <<<.
And I have seen many comments about NOT using End.
So
(1) what exactly does End do that is so bad?
(2) seen Stop too.
(3) how can I exit the app politely but immediately?

How about calling a sub in a module that calls _unload in the main form?

However, there may be flags set that the main form is supposed to process so
I would have to clear all of those and not do that processing.

Educate me.

From: C. Kevin Provance on
Educate yourself. Google. Why do you expect the rest of us to repeat answers that are already out there, many of those which have come from archives of this exact ng? Don't be so fvcking lazy dude.

--
2025
If you do not believe in time travel,
your beliefs are about to be tempered.

http://www.facebook.com/group.php?gid=43606237254
"Bee" <Bee(a)discussions.microsoft.com> wrote in message news:97B227F0-BB50-4D26-B16C-56C12F432F35(a)microsoft.com...
: Down in the bowels of my VB6 app I need to ask the user to do something or
: "die".
: That is the way it is and I cannot change this structure.
: I have seen applications that use >>> End <<<.
: And I have seen many comments about NOT using End.
: So
: (1) what exactly does End do that is so bad?
: (2) seen Stop too.
: (3) how can I exit the app politely but immediately?
:
: How about calling a sub in a module that calls _unload in the main form?
:
: However, there may be flags set that the main form is supposed to process so
: I would have to clear all of those and not do that processing.
:
: Educate me.
:
From: mscir on
On 4/2/2010 5:45 PM, Bee wrote:
> Down in the bowels of my VB6 app I need to ask the user to do something or
> "die".
> That is the way it is and I cannot change this structure.
> I have seen applications that use>>> End<<<.
> And I have seen many comments about NOT using End.
> So
> (1) what exactly does End do that is so bad?
> (2) seen Stop too.
> (3) how can I exit the app politely but immediately?
>
> How about calling a sub in a module that calls _unload in the main form?
>
> However, there may be flags set that the main form is supposed to process so
> I would have to clear all of those and not do that processing.
>
> Educate me.

I'd read this:

http://vbcity.com/forums/t/96612.aspx

Also I've saved these over the years:

1------------------------------------------------------------------------
Subject: Re: Unload Form, Set Form=Nothing, End, program doesn't end!
Date: Thu, 19 Mar 1998 17:34:52 -0500
From: "A Consultant" <consultant(a)towers.com>
Newsgroups: microsoft.public.vb.general.discussion

Make sure that you turn OFF all TIMER controls! Forms stay loaded if
timers still active.

Sincerely,
Marc Schreiber tech(a)sunbeltinc.com

2-------------------------------------------------------------------------------------------------------------------------
Simply stated, you should never use the END keyword. Period. Unloading
your last form and having all dependant object properly freed when you
unload the the last form and set it to NOTHING should be enough to get
VB to finish cleaning up and shutdown your app.

Best Regards,

Darryll D. Petrancuri
Principal
Dynamic Programming Services Corp.


3----------------------------------------------------------------------------------------------------------------------------------------------------------------------
if you use API calls to create hDC, hBitmap or other objects, release
them close all files, recordsets, databases, etc set all object
variables, collections, etc =Nothing unload all forms set all form names
=Nothing
do not use END. Ever. The order is not generally as important as being
sure to free up all of the resources that you have allocated. Order may
be important in specific cases (e.g. class A contains references to
class B which has references to something else (or even back to class A)
so you should be careful to release things so that the references remain
consistent. Once everything is released your application will end by
itself. If you have to use END then you have missed something.

VB OnLine Magazine:
http://www.vbonline.com/vb-mag
http://www.vbonline.com/vb-mag/qaweb

4--------------------------------------------------------------------------
There should be no need to ever use the End statement if you are really
unloading all forms, objects, etc. and freeing all resources. If all
objects are unloaded, the app will terminate by itself. To figure out
what's not unloading, I would put some logging code in each form's Load
and Unload, each object's Initialize & Terminate events to track the
loading and unloading of your objects. You'll probably find that
something wasn't able to unload or you forgot to explicitly unload it.

Yes, putting 'Set frmName = Nothing' in the Unload event of all forms is
a still good idea in VB5

Jonas
TRION Technologies


5--------------------------------------------------------------------------
Actually, the point of the statement is backwards compatibility for
older code, not convenience. Whether you believe it or not, END is evil.
VB does quite a bit of work for you in the background to isolate you
from the implementation nightmares of low-level Windows and COM
programming, but END simply halts execution of your code and VB does not
clean up any of the complicated work associated with properly
deallocating objects and memory. This can cause DLLs to be frozen in
memory and applications to stop responding but refuse to quit.
The proper and correct way to shut an app down is to make sure all
object references have been terminated and all forms have been
explicitly unloaded. S, don't take my word for - look up any of MS' many
papers on the subject.
Just another $.02.

-Rob


>Here's a weird one. I've written an app that won't quit on one
>particular machine.
>
>I've written a simple VB6 app. The app runs just fine on my PC (NT4
>Workstation, SP3) but when I run it on the NT4 Server (also SP3, Option
Pack 4, with Visual Studio 6 installed as well), the app won't
completely die.
The code executes, the forms unload, the objects appear to drop (when
set to >nothing), but a process remains - I can still see "myprog.exe"
in the Task >Manager. If I try to use any app to see what resources it
is still using, the app trying to access myprog.exe will freeze up. All
I can do is kill the >phantom process - heck, with the phantom process
running, Windows NT Server won't even shutdown!

Have you closed all files, recordsets, databases, sockets, etc?
Have you stopped all timers?
Have you set all your module-level and global object variables =Nothing?
Have you done the same with the implicit form variables (e.g. Set
Form1=Nothing)?
Did you release any GDI or other resources you allocated via API calls?

When an app remains in memory it is usually because you have not
released some resource that you allocated so something remains in
memory. The various flavors of Windows do cleanup slightly differently
and having different revs of the supporting DLLs on systems can also
cause it to behave differently on different boxes. Check your code and
make sure you are cleanly releasing everything when you are ready to
shut down.

6---------------------------------------------------------------------------
Public Sub CleanUp()
' Unload and Release Memory for All Forms Loaded
Dim FormX As Form
' Check to ensure that all forms are unloaded and that the
' memory is released
For Each FormX In Forms
Unload FormX
Set FormX = Nothing
Next FormX
End Sub

--- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: MM on
On Fri, 2 Apr 2010 21:48:53 -0400, "C. Kevin Provance" <*@*.*> wrote:

>Educate yourself.

Bit rude! My old mum used to say, if you can't say anything nice,
don't say anything!

MM
From: AR88 Enthusiast on
Agreed. And your thinly veiled foul language is not clever either. Sign of a
poor vocabulary.

"MM" <kylix_is(a)yahoo.co.uk> wrote in message
news:j9qdr5t2q3k95nq7pt29ougqbro0acf63r(a)4ax.com...
> On Fri, 2 Apr 2010 21:48:53 -0400, "C. Kevin Provance" <*@*.*> wrote:
>
>>Educate yourself.
>
> Bit rude! My old mum used to say, if you can't say anything nice,
> don't say anything!
>
> MM


 |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11
Prev: Convert UTF-16 Unicode to UTF-8 Unicode?
Next: API-Guide