+ Reply to Thread
Results 1 to 2 of 2

What's the difference between 'Set UserForm1=Nothing' and 'Unload UserForm1' ?

  1. #1
    Zoo
    Guest

    What's the difference between 'Set UserForm1=Nothing' and 'Unload UserForm1' ?

    I have 'UserForm1' and Module1.
    In UserForm1:

    Private Sub UserForm_Initialize()
    Debug.Print "Initialized"
    End Sub

    Private Sub UserForm_Terminate()
    Debug.Print "Terminated"
    End Sub

    In Module1:

    Sub Main()

    Debug.Print "Set UserForm1 to nothing"
    Set UserForm1 = Nothing

    Debug.Print

    Debug.Print "Unload UserForm1"
    Unload UserForm1

    End Sub

    After running 'Main', the result is:
    -------------------------
    Set UserForm1 to nothing

    Unload UserForm1
    Initialized
    Terminated
    -------------------------
    This means Unload statement creates a new instance of UserForm before
    destroying it.
    What makes the difference between Set and Unload?
    Are there any other differences between those?



  2. #2
    Wendell A. Clark
    Guest

    Re: What's the difference between 'Set UserForm1=Nothing' and 'Unload UserForm1' ?

    setting an object to nothing returns the memory....

    --
    Wendell A. Clark, BS
    -------------------------------------

    CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may
    contain confidential and privileged information for the use of the
    designated recipients named above. If you are not the intended recipient,
    please notify us by reply e-mail. You are hereby notified that you have
    received this communication in error and that any review, disclosure,
    dissemination, distribution or copying of it or its contents is prohibited.
    If you have received this communication in error, please destroy all copies
    of this communication and any attachments. Contact the sender if it
    continues.


    "Zoo" <[email protected]> wrote in message
    news:[email protected]...
    >I have 'UserForm1' and Module1.
    > In UserForm1:
    >
    > Private Sub UserForm_Initialize()
    > Debug.Print "Initialized"
    > End Sub
    >
    > Private Sub UserForm_Terminate()
    > Debug.Print "Terminated"
    > End Sub
    >
    > In Module1:
    >
    > Sub Main()
    >
    > Debug.Print "Set UserForm1 to nothing"
    > Set UserForm1 = Nothing
    >
    > Debug.Print
    >
    > Debug.Print "Unload UserForm1"
    > Unload UserForm1
    >
    > End Sub
    >
    > After running 'Main', the result is:
    > -------------------------
    > Set UserForm1 to nothing
    >
    > Unload UserForm1
    > Initialized
    > Terminated
    > -------------------------
    > This means Unload statement creates a new instance of UserForm before
    > destroying it.
    > What makes the difference between Set and Unload?
    > Are there any other differences between those?
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1