473,651 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1411
this may be of some help

http://blogs.msdn.com/ericlippert/ar...28/122259.aspx
"Ven" <Ve*@discussion s.microsoft.com > wrote in message
news:3F******** *************** ***********@mic rosoft.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*@discussion s.microsoft.com > wrote in message
news:3F******** *************** ***********@mic rosoft.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
2740
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 the main difference between closing the object and setting them to nothing. I've read several articles that Access may not release some resources if you don't force it to, so I'm just wondering which of the two (setting them to nothing or...
18
18353
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 a remote update of tables and fields and can't find enough information on these things. Also, how do you index a field in code?
8
2258
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 happens. dim filt as string ... build filter string... UserControl.ReportFilter = filt
0
2642
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 I am having is that when I have a value in the propertygird and edit that, I want the listbox to have the selectvalue equal to the value that is being edited. Just to make it clearer: PropgridVal = Germany Datasource=
11
3482
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 set the property of the instance to the value here is an example of what the method might look like public void SetProperty(object instance, string property, object value) {
10
1675
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() .... blah blah blah... .... Set MyDB = Nothing Set rstType17CorrespRecs = Nothing
6
1672
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
4540
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 TypeOf obj Is IDisposable Then DirectCast(obj, IDisposable).Dispose()
6
3558
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." http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/6732ea8e7016bd24/70608745c29d048b?lnk=gst&q=can%27t+set+enum+to+nothing#70608745c29d048b Just to expand the understanding of the problems this behavior can cause, because a typical enumeration (enum) is...
0
8275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8802
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8697
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8579
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7297
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2699
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.