
12-14-2004, 07:29 AM
|
|
Enthusiast
Retired Leader * Expert *
|
|
Join Date: Apr 2002
Location: Bellevue, WA.
Posts: 3,233
|
|
is know as auto instancing. As soon as this line of code is run, VB will create a new variable x with the properties and attributes of y. Auto-instancing variables can't be tested against the Nothing value. In fact, as soon as you use one and try to set it to nothing, VB relentlessly creates a new instance of the object. For this reason alone, it is generally not a good practice to instanciate an object this way. That is why Flyguy's approach is the best method as it allows you to remove the object from memory at will. If an object is created with the As New key word and is referenced in the code, it really will exist until the application ends.
|
|