Home All Groups Group Topic Archive Search About
Author
5 Aug 2010 7:43 PM
BeeJ
I am trying to close an external VB6 app.
I am setting all timers .Enabled = False.  ( I read that this is not
necessary but I do it anyway )
I am UnLoading all Forms.  Well, I am commanding it but maybe something
is not letting me close.
Do I need to disable API timers?
In one I have COMM open so I set PortOpen to False.
Most of my external apps close properly.
What else do I need to do?

Author
5 Aug 2010 10:19 PM
ralph
On Thu, 05 Aug 2010 12:43:12 -0700, BeeJ <nospam@nowhere.com> wrote:

A few questions inline:

>I am trying to close an external VB6 app.

What exactly do you mean by an "external VB6 app"? Do you mean a
free-standing executable?
Does it appear to close properly in the IDE but fail when released?

>I am setting all timers .Enabled = False.  ( I read that this is not
>necessary but I do it anyway )
>I am UnLoading all Forms.  Well, I am commanding it but maybe something
>is not letting me close.

Need to see how you are "commanding" this. It is easy to accidently
make a call which "re-loads" a form.

>Do I need to disable API timers?
>In one I have COMM open so I set PortOpen to False.
>Most of my external apps close properly.
>What else do I need to do?
>

VB normally "hangs" because an object reference (Form, Class, external
library, etc.) is left open, (not set to Nothing). Usually API items,
etc. are cleaned up by the O/S - there may be some delay if watching
in the TaskManager, but seldom cause a program to "hang". Though
ALWAYS best to do your own cleanup.

One defensinve debugging practice is to provide a count and a log of
opening/closing to check objects of your own creation.

Take a look at the VB Class Builder. If you select the "debug"
options, you will note VB will insert 'debugmode' code. Create a
simple class, save it, then examine the code. You can easily adapt
this mechanism to wrap your Forms and Classes.
Author
5 Aug 2010 10:31 PM
Kevin Provance
"ralph" <nt_consultin***@yahoo.net> wrote in message
news:5o7m5658cvknk56v38i75r73ttjm6trs8t@4ax.com...
:
: VB normally "hangs" because an object reference (Form, Class, external
: library, etc.) is left open, (not set to Nothing). Usually API items,
: etc. are cleaned up by the O/S - there may be some delay if watching
: in the TaskManager, but seldom cause a program to "hang". Though
: ALWAYS best to do your own cleanup.

Ouch.  Open a DC and leave it that way.  The app exiting however properly
will still leave a great big leak.  I've always been taught that VB is
*supposed* to clean up for you, but never to trust it to do so.  That said -
to the OP - clean up/destory everything you create.  It leaves less to
chance.
Author
5 Aug 2010 11:37 PM
ralph
Show quote Hide quote
On Thu, 5 Aug 2010 18:31:37 -0400, "Kevin Provance" <k@p.c> wrote:

>"ralph" <nt_consultin***@yahoo.net> wrote in message
>news:5o7m5658cvknk56v38i75r73ttjm6trs8t@4ax.com...
>:
>: VB normally "hangs" because an object reference (Form, Class, external
>: library, etc.) is left open, (not set to Nothing). Usually API items,
>: etc. are cleaned up by the O/S - there may be some delay if watching
>: in the TaskManager, but seldom cause a program to "hang". Though
>: ALWAYS best to do your own cleanup.
>
>Ouch.  Open a DC and leave it that way.  The app exiting however properly
>will still leave a great big leak.  I've always been taught that VB is
>*supposed* to clean up for you, but never to trust it to do so.  That said -
>to the OP - clean up/destory everything you create.  It leaves less to
>chance.

lol

Tis true.

I unfortunately often dance around such subjects simply because if one
states one or the other as fact - there will always be someone who
says the opposite. <g>

[Witness the occasional use of 'End' discussions. <g>]

Frankly I'm a wimpy programmer. I always cleanup everything. Don't
care if it is going out of scope, I know its OK, or whatever - I new
it, I destroy it. I set it, I nothing it.
(Is that a legitimate phrase? <g>)

-ralph
Author
6 Aug 2010 3:30 AM
Kevin Provance
"ralph" <nt_consultin***@yahoo.net> wrote in message
news:86im569on1d4vbhc1jrl7s83o3qhjm0352@4ax.com...
: I unfortunately often dance around such subjects simply because if one
: states one or the other as fact - there will always be someone who
: says the opposite. <g>

In this case, the truth lies somewhere in between.  For the most part, VB
does and will clean up it's own messes, but don't trust it to.  As far as
the API is concerned, know ahead of time if what you open or create needs to
be destroyed or closed.  Some don't, most do.  The only way to be sure,
except for making a list, is to check the specific API call in the MSDN and
note the text under "Return Value".  If it requires special handling, it
will tell you.

: [Witness the occasional use of 'End' discussions. <g>]

Or Google them as I suggest on occasion.  <g>
:
: Frankly I'm a wimpy programmer. I always cleanup everything. Don't
: care if it is going out of scope, I know its OK, or whatever - I new
: it, I destroy it. I set it, I nothing it.
: (Is that a legitimate phrase? <g>)

Some other participants might find this blue collar and lazy.  I disagree.
Show quoteHide quote
:-)
Author
5 Aug 2010 10:55 PM
BeeJ
Thanks for the clues.

BTW I sometimes get the error message 'too many quoted lines' when I
try to reply.  What is that?
Author
5 Aug 2010 11:23 PM
Tony Toews
On Thu, 05 Aug 2010 15:55:06 -0700, BeeJ <nospam@nowhere.com> wrote:

>BTW I sometimes get the error message 'too many quoted lines' when I
>try to reply.  What is that?

Probably coming from your newsreader.   The quoted lines are the lines
which start with >

Tony (sometimes known as the trim king)

--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
  updated see http://www.autofeupdater.com/
Author
8 Aug 2010 7:21 PM
Nobody
"BeeJ" <nospam@nowhere.com> wrote in message
news:i3f48c$ilj$1@speranza.aioe.org...
> I am UnLoading all Forms.  Well, I am commanding it but maybe something is
> not letting me close.

After that, use this routing to print what forms that are still loaded:

Public Sub PrintAllForms()
    Dim frm As Form

    For Each frm In Forms
        Debug.Print "PrintAllForms: " & frm.name
        OutputDebugString "PrintAllForms: " & frm.name
    Next
End Sub


> Do I need to disable API timers?

Yes, in case in the timer routine(or any routine it calls or event that it
triggers) accesses a property or a method causing a form to reload.