Close Without End

From HashVB
Revision as of 01:16, 20 October 2005 by Wakjah (Talk | contribs)

Jump to: navigation, search

A common misconception among people new to programming is that it's OK to use the End keyword.

Well it's not.


Using End is like driving into a 6 foot btick wall. It does no clean-up, nothing, it just ends the app.

Why is this bad?

For one it often causes memory leaks. As well as this you cannot use it if you're subclassing.

So what do you do?

You loop through the forms and Unload each one in turn - like this:

 Dim f As Form
 For Each f In Forms
     Unload f
 Next f

Simple as that.