README.md

December 4, 2022 ยท View on GitHub

How-to exit an application correctly

Description

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

More Info

Submitted On2001-08-12 16:45:30
BySlider
LevelBeginner
User Rating3.9 (27 globes from 7 users)
CompatibilityVB 4.0 (32-bit), VB 5.0, VB 6.0
CategoryObject Oriented Programming (OOP)
WorldVisual Basic
Archive FileExit Appli244968122001.zip

Source 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.