Search Tools Links Login

How-to exit an application correctly


Visual Basic 6, or VB Classic

This article demonstrates how to exit an application cleanly with user prompting (if required) without using the END Statement.

Original Author: Slider

Code

Too many programmers these days use the end statement in their programs and under certain conditions leave fragements behind in memory, the application doesn't shut down fully, or in extreme cases cause GPFs.

To unload applications correctly, the statement 'Unload Me' should be used. The 'Form_QueryUnload' event will be triggered and at this point we should ask the user what to do. The reason why we should put a "Save Changes" propmt in the 'Form_QueryUnload' event is that there is more than one way to close an application. If the System Shutdown is invoked, or the Close "X" button is pressed, then we can catch these events and give the user a chance to save thier work.
Attached are two framework applications to demostrate how to close A) SDI application and B) MDI application.
If you find this article & code useful, then please leave me a comment and I'll add more useful articles.

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 90 times

Categories

Visual Basic 6

Attachments

Exit Appli244968122001.zip
Posted: 9/3/2020 3:45:00 PM
Size: 5,430 bytes


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.