Re: Syntax to QUIT the running App - To Clarify...

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



well Mike don`t fall in the same pitfall as i did when dealing with this
person

we all know that using End to terminate a forms applcation in VB is bad
coding parctice

Maybe you now understand the mistake i made when dealing earlier with this
person , and you said so yourself we are paticipating in this newsgroup to
help and learn from each other, not to have childish arguments


the only situation when End might be valid to use is in a module only app

<!------ explanation for those who might be interested
When executed, the End statement resets all module-level variables and all
static local variables in all modules. To preserve the value of these
variables, use the Stop statement instead. You can then resume execution
while preserving the value of those variables.

Note The End statement stops code execution abruptly, without invoking the
Unload, QueryUnload, or Terminate event, or any other Visual Basic code. Code
you have placed in the Unload, QueryUnload, and Terminate events of forms and
class modules is not executed. Objects created from class modules are
destroyed, files opened using the Open statement are closed, and memory used
by your program is freed. Object references held by other programs are
invalidated.

The End statement provides a way to force your program to halt. For normal
termination of a Visual Basic program, you should unload all forms. Your
program closes as soon as there are no other programs holding references to
objects created from your public class modules and no code executing.
----->




"MikeD" wrote:

>
> "Bob Butler" <tiredofit@xxxxxxxxxx> wrote in message
> news:ekoKJUzrFHA.3080@xxxxxxxxxxxxxxxxxxxxxxx
> > "Ted" <2000@xxxxxxxxxx> wrote in message
> > news:%23quNP2yrFHA.2768@xxxxxxxxxxxxxxxxxxxx
> >> This helps:
> >>
> >> Private Sub Command1_Click()
> >> Unload Me
> >> End Sub
> >>
> >> Private Sub Form_Unload(Cancel As Integer)
> >> Call iEnd
> >> End Sub
> >> Public Sub iEnd()
> >> End
> >> End Sub
> >
> > NO. VB apps *never* need to use END and using it when the app is not
> > already ending wthout it can result in problems as resources may not be
> > properly released. Unload all forms and make sure that no code is running
> > and your app will end cleanly.
>
>
> This should be interesting.... let's see if Ted takes potshots at Bob and
> Rick for criticizing his code. <g>
>
> If *I* had made this very same comment about using End, you can bet he'd say
> I didn't know what I was talking about (and that I probably read in a book
> that End was bad).
>
> I'm not trying to start anything anew, Ted, so don't get all defensive. I
> just find it interesting how your "reaction" is based on *who* replied,
> rather than *what* was said in the reply.
>
> --
> Mike
> Microsoft MVP Visual Basic
>
>
>
.



Relevant Pages

  • Re: Syntax to QUIT the running App - To Clarify...
    ... >> Unload to unload the last from open it the app - which appears to ... > Note The End statement stops code execution abruptly, ... Code you have placed in the Unload, QueryUnload, and Terminate ... > events of forms and class modules is not executed. ...
    (microsoft.public.vb.general.discussion)
  • Re: Syntax to QUIT the running App - To Clarify...
    ... > Unload to unload the last from open it the app - which appears to entirely ... Note The End statement stops code execution abruptly, ... Code you have placed in the Unload, QueryUnload, and Terminate ... events of forms and class modules is not executed. ...
    (microsoft.public.vb.general.discussion)
  • Re: Possible huge clue into unmanged/managed problem
    ... If you happen to abort a thread asynchronously, that means an exception can ... when the exception is thrown during the execution of the finalize clause ... > terminate the whole application if I only want to terminate one thread? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Possible huge clue into unmanged/managed problem
    ... If you happen to abort a thread asynchronously, that means an exception can ... when the exception is thrown during the execution of the finalize clause ... > terminate the whole application if I only want to terminate one thread? ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Form wont show up for the first time
    ... >> I have a strange problem. ... > Ignore the suggestions about the refresh method, ... > put an End statement in your main form's unload event. ... Terminate events, and objects you've created will not get their Terminate ...
    (microsoft.public.vb.general.discussion)