Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Diff. btw. Unload and Set obj=Nothing? (Win2000/O2K -UK)

    Hi,

    (Env. Win2000, Off.2000-UK)

    Can someone explain me the difference between the
    "Unload" and the "Set myObj=Nothing"

    According to the help the "Unload" statement:
    "Removes an object from memory.

    When an object is unloaded, it's removed from memory and
    all memory associated with the object is reclaimed. Until
    it is placed in memory again using the Load statement, a
    user can't interact with an object, and the object can't
    be manipulated programmatically."


    I thought "Set myObj=Nothing" did the same ?
    - is that correct ??


    ;o) henrik
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Diff. btw. Unload and Set obj=Nothing? (Win2000/O2K -UK)

    The online help is slightly confusing here. Load and Unload don't apply to objects in general, but are specific to UserForms (and forms controls). When you hide a UserForm, it is still loaded in memory, so that you can get at the value of text boxes etc.; you use Unload to remove the UserForm from memory after you have retrieved the information you need.

    So you could have code like this:

    <font face="Georgia">UserForm1.Hide
    strLastName = UserForm1.TextBox1
    Unload UserForm1

    Set objectvariable = Nothing</font face=georgia> is used to release object memory for all kinds of objects. For example:

    <font face="Georgia">Dim doc As Document
    Set doc = Documents.Open("C:WordReport.doc")
    ' do something with the document
    ' ...
    doc.Close SaveChanges:=wdSaveChanges
    Set doc = Nothing</font face=georgia>

    You would get an error message if you tried to Load or Unload the doc variable, since it is not a UserForm.

  3. #3
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Diff. btw. Unload and Set obj=Nothing? (Win2000/O2K -UK)

    Thanks Hans,

    So simple and obvious, when explained this way...

    ;o)) Henrik
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't 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
  •