Hi "First,"
 
> Another writer said that "end" is not to be used.  I think he 
> has it confused with "Stop" 

No, I did not confuse anything.

END is the ultimate evil in Visual Basic. Avoid it like the plague.


> I went back and checked help and it says just what I always 
> knew -- End completely wipes the program from memory. 

Have you read Hardcore VB yet? Have you debugged memory after you've
terminated a program using END? Have you tried any "non-end"
alternatives?

Are you willing to trust the tech writers at microsoft with the
reliability of your applications and the computers they run on?


> If you left any files open, it closes them.

ONLY files that are opened via 'open' calls. And this, too, can be
fudged with End if the open call is within certain object methods of
activex controls on user forms or user classes.

This is also in the help file, coincidentally you left it out:

  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.


> Of course, Unload me will only unload the form that we're in. 
> So if you have other forms still open, then they will remain 
> open after the End command.

End terminates the application and any programmatic access to those
forms. Handles are lost and the forms may close gracefully ONLY if
there are no event procedures relating to the rest of the
application that are called during queryunload, unload or terminate
events. Even then, the form will remain in memory even if it is
closed.


> That's the one that will close any and all forms 
> that are open.  After using that code, then I would
> say "End"

The only reason to EVER use end is if you're a sloppy coder and you
do not take responsibility for the objects and references you create
within your application. Every VB program will close gracefully and
completely remove itself from memory at the end of any procedure at
which the object count is zero and there are no forms loaded.
Period.

If your application is NOT closing gracefully, requiring you to use
END to kill it, then you're not coding correctly. There's no nice
way to put it. It's a very simple truth.

Never Use End:
  http://ReliableAnswers.com/p/?/VB/Never*Use*End


Regards,

Shawn K. Hall
VBHelp Moderator
http://ReliableAnswers.com/





'// =======================================================
    Rules : http://ReliableAnswers.com/List/Rules.asp
    Home  : http://groups.yahoo.com/group/vbHelp/
    =======================================================
    Post  : [email protected]
    Join  : [EMAIL PROTECTED]
    Leave : [EMAIL PROTECTED]
'// =======================================================
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/vbhelp/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to