
Help: Control Box doesn't work right.
Quote:
> I have VB Pro 4. I am writing 32 bit code for Win95. If I create a
> button w/ "end" for the code, my program exits fine. However, when I
> use the "x" on the control box my program quits but the "close program
> dialog box" that you get w/ Ctrl-Alt-Del shows my program still being
> active????????????????? Help me make this control box work.
Hi Shawn,
This seems to be a common misconception. It is documented in the KB
but not in the VB Help file.
Closing (ie. unloading) a window doesn't end the app, which still has
all the module-level code in memory, and perhaps other hidden (or
merely unloaded) forms and other code modules.
'Unload' (or closing using control box) merely unloads the graphical
interface of the form. Compare 'Load', which merely loads the
graphical interface. The code for each form is moved into memory when
the Initialise event fires, and destroyed when the Terminate event fires.
You can initialise any module by referencing it or instantiating it,
and can terminate it with 'Set FORM/CLASS = Nothing'.
This ties in with how a class works: a class is just the 'code' part
of a form, without the graphical interface. It still has Initialise
and Terminate events, but no Load or Unload.
However, the End statement does all this for you if you want to end
the whole app. Put 'End' in the Unload event of the app's main form.
Steve.