473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Setting object to Nothing

Ven
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
Jan 6 '06 #1
2 1403
this may be of some help

http://blogs.msdn.com/ericlippert/ar...28/122259.aspx
"Ven" <Ve*@discussions.microsoft.com> wrote in message
news:3F**********************************@microsof t.com...
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

Jan 6 '06 #2
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/ar...28/122259.aspx
"Ven" <Ve*@discussions.microsoft.com> wrote in message
news:3F**********************************@microsof t.com...
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


Jan 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ryan | last post by:
Hi, I am hoping somebody can provide a clear picture on this topic. When is it necessary to specifically close and/or set an object (recordset, database, variable, etc.)to nothing and what is...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
8
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing...
0
by: David J | last post by:
Hi, I am strugling with the propertygrid and a listbox. I am using the universaldropdowneditor from the codeproject (code below). However I am populating the listbox via a datasource. The problem...
11
by: Alexander Walker | last post by:
Hello I would like to write a method that allows me to pass a reference to an instance of a class, the name of a property of that class and a value to set that property to, the method would then...
10
by: MLH | last post by:
I was wondering if setting object vars to Nothing near the end of a sub procedure was beneficial at all - since they (the OV's) are about to go out-a-scope anyway? For example, Sub MySub()...
6
by: MLH | last post by:
MyRst.Close Set MyRst = Nothing MyDB.Close Set MyDB = Nothing Would the above be the correct order in which to conduct the operations?
9
by: Doug Glancy | last post by:
I got the following code from Francesco Balena's site, for disposing of Com objects: Sub SetNothing(Of T)(ByRef obj As T) ' Dispose of the object if possible If obj IsNot Nothing AndAlso...
6
by: DippyDog | last post by:
This is an old old post that I'm referencing regarding what happens when you set an integer variable to Nothing. It gets set to zero, not "Nothing." ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.