Setting object to Nothing

Discussion in 'ASP General' started by Ven, Jan 6, 2006.

  1. Ven

    Ven Guest

    If an Object is holding a valid reference to an Object, should I set it to
    Nothing before I set it to a another Object of the same type?

    ex:
    Dim objNode
    Set objNode=Node1 ' Say node1 is some expression
    ' Do some processing and then. Should I set it to Nothing?

    Set objNode=Node2 ' Say node1 is some expression

    Is it the same in ASP and VB

    Thank You
     
    Ven, Jan 6, 2006
    #1
    1. Advertising

  2. Ven

    Slim Guest

    this may be of some help

    http://blogs.msdn.com/ericlippert/archive/2004/04/28/122259.aspx


    "Ven" <> wrote in message
    news:...
    > If an Object is holding a valid reference to an Object, should I set it to
    > Nothing before I set it to a another Object of the same type?
    >
    > ex:
    > Dim objNode
    > Set objNode=Node1 ' Say node1 is some expression
    > ' Do some processing and then. Should I set it to Nothing?
    >
    > Set objNode=Node2 ' Say node1 is some expression
    >
    > Is it the same in ASP and VB
    >
    > Thank You
    >
    >
     
    Slim, Jan 6, 2006
    #2
    1. Advertising

  3. Hmm... Thats a lot of info to take in.

    Simply the answer is no you don't need to assign nothing before assigning
    another object reference to an existing one.

    Nothing is not a magic word that causes VB to do drastically different things.

    Basically what VB does when you use the SET assignment (Set objA = objB) is
    this:-

    Test objA for non-null value.
    If non-null value found treat it as a pointer to an object and call the
    objects release method
    copy value of objB to objA
    Test objA for non-null value
    If non-null value found treat it as a pointer to an object and call the
    objects AddRef method.

    That's it.

    Nothing is simply a Constant null object pointer.

    Anthony.

    "Slim" wrote:

    > this may be of some help
    >
    > http://blogs.msdn.com/ericlippert/archive/2004/04/28/122259.aspx
    >
    >
    > "Ven" <> wrote in message
    > news:...
    > > If an Object is holding a valid reference to an Object, should I set it to
    > > Nothing before I set it to a another Object of the same type?
    > >
    > > ex:
    > > Dim objNode
    > > Set objNode=Node1 ' Say node1 is some expression
    > > ' Do some processing and then. Should I set it to Nothing?
    > >
    > > Set objNode=Node2 ' Say node1 is some expression
    > >
    > > Is it the same in ASP and VB
    > >
    > > Thank You
    > >
    > >

    >
    >
    >
     
    AnthonyWJones, Jan 6, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Kamoski

    setting to Nothing

    Mark Kamoski, Aug 7, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,086
    Robert Jacobson
    Aug 7, 2003
  2. Srinivasa Raghavan Sethuraman
    Replies:
    0
    Views:
    567
    Srinivasa Raghavan Sethuraman
    Jun 30, 2004
  3. mjkahn

    Setting ASP object variables to Nothing

    mjkahn, May 30, 2005, in forum: ASP General
    Replies:
    1
    Views:
    126
    Bob Barrows [MVP]
    May 30, 2005
  4. dotnettester

    Setting object = nothing after Response.end

    dotnettester, Sep 12, 2005, in forum: ASP General
    Replies:
    6
    Views:
    151
    Dave Anderson
    Sep 13, 2005
  5. Devin Jeanpierre
    Replies:
    2
    Views:
    492
    Devin Jeanpierre
    Feb 14, 2012
Loading...

Share This Page