Results 1 to 4 of 4

Thread: Another easy question...

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    34
    How do you unload forms from within your code. And I dont mean HIDING them.

    thanks,
    Wick

  2. #2
    Guest
    Use the Unload method

    Code:
    'Will unload Form2
    Unload Form2
    
    'Will unload the current Form you are in
    Unload Me

  3. #3
    Guest
    You are best to free up any resources in use from your program as well. You can do this by unloading all forms:

    Code:
    Public Sub UnloadAllForms()
    Dim OfTheseForms As Form
    For Each OfTheseForms In Forms
    Unload OfTheseForms
    Set OfTheseForms = Nothing
    Next OfTheseForms
    End Sub
    Or just one:

    Code:
    Unload Form1
    Set Form1 = Nothing

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Forms are funny things in VB...

    They are in reality "Classes" and the second you show your form it has actually created an instance.

    The problem then is you cannot get rid of the actual forms themselves unless you actually created a NEW instance of them and use it.

    As Matthew said above, if you "Dim" an instance of your form, use it, unload it and then set it to nothing you have successfully gotten rid of every last trace of the form from memory.

    If however you just started using the form by calling its name directly you will have that form hanging around and although you can unload it I am not sure if you can set it to nothing....

    People often get confused with VB5 and VB6 thinking that forms are some "special" kind of entity when they are really classes... As many people don't understand object-orientation and classes they fail to understand how forms REALLY work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width