Home
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
 
 
 
 
TitleUnload a form and clear the variables it contains
Keywordsforms, unload, clear, variables
CategoriesTips and Tricks
 
Forms have two parts: a visible part and an invisible part. The visible part is what you see on the screen. The invisible part holds the form's variables.

When you use Unload to unload a form, the visible part is destroyed but the invisible part is not. If you redisplay the form, its variables have the same values they did when you unloaded the form.

To clear the form's variables, set the reference to the form object to Nothing. Do this even if you are using the special instance of the form named after itself, even though that doesn't seem to make sense. Later you can use the special instance variable to redisplay the form with reset values.

 
' Show Form2.
Private Sub Command1_Click()
    Form2.Show
End Sub

' Unload the form's visible component only.
Private Sub Command2_Click()
    Unload Form2
End Sub

' Unload the form's visible and invisible components.
Private Sub Command3_Click()
    Unload Form2
    Set Form2 = Nothing
End Sub
 
 
Copyright © 1997-2001 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated