Re: Beginner question
- From: "Rick Rothstein" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx>
- Date: Thu, 30 Jun 2005 08:35:22 -0400
> > the "dreaded" End
> Another thing I've not heard of. What's so bad about end?
>From an old post of mine...
Never, never, never, never, ever use the End statement to terminate your program.
End should ***NEVER*** be used in VB. When you start writing more complex code, you will find that in certain situations, VB needs to do some cleaning up (and you need to help it). You can go to this Google newsgroup link
and look up the exact word "vb" and the exact phrase "end statement" (leave off the quotes in both of these) to find the many ways people have explained the why and what of not using the End statement. Suffice it to say that the End statement stops your program in the same way running into a brick wall stops your car... immediately. You don't get a chance to coast to a stop and turn your key to the off position, open the door and exit the vehicle. The same thing happens with the End statement... BOOM!, everything stops dead in its tracks right then and there and the program ends. The moral is... NEVER, NEVER, NEVER use the End statement in your program! (And, in the same way, using that "solid square" icon on VB's Toolbar, or clicking End in the Run menu, to stop your project during development is the identical equivalent of executing an End statement in code... you shouldn't do that either.)
Consider this... From the VB Help Files: "More About Forms"
"The End statement ends an application immediately: no code after the End statement is executed, and no further events occur. In particular, Visual Basic will not execute the QueryUnload, Unload or Terminate event procedures for any forms. Object references will be freed, but if you have defined your own classes, Visual Basic will not execute the Terminate events of objects created from your classes."
"In addition to the End statement, the Stop statement halts an application. However, you should use the Stop statement only while debugging, because it does not free references to objects."
Rick - MVP
- Prev by Date: Re: Listbox Hell
- Next by Date: Re: Toolbars in word documents opened in Web browser control
- Previous by thread: Re: Beginner question
- Next by thread: Re: Toolbars in word documents opened in Web browser control