Assigning null to an Object

How to assign NULL value to an Object?
BobSamonikAsked:
Who is Participating?
 
svd2002Connect With a Mentor Commented:
As said by ghimireniraj, you can set
Set MyObject = Nothing

And then check
If MyObject Is Nothing Then
  ' Code
End If

You said that you can't test it on "Nothing". Why?
0
 
ghimirenirajCommented:
Set MyObject = Nothing

Is it?


--Niraj


0
 
BobSamonikAuthor Commented:
I can't test it on Nothing and if I assign Nothing
IsNull(MyObject) returns false
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
BobSamonikAuthor Commented:
I can't test it on Nothing and if I assign Nothing
IsNull(MyObject) returns false
0
 
ghimirenirajCommented:
From MSDN:

IsNull Function Example
This example uses the IsNull function to determine if a variable contains a Null.

Dim MyVar, MyCheck
MyCheck = IsNull(MyVar)   ' Returns False.

MyVar = ""
MyCheck = IsNull(MyVar)   ' Returns False.

MyVar = Null
MyCheck = IsNull(MyVar)   ' Returns True.




--Niraj
0
 
BobSamonikAuthor Commented:
MyCheck has to be declared as an Object becouse I use its methods later
And if a declare it as an object I can't assign Null to it or i don't know how.
0
 
BobSamonikAuthor Commented:
hey
that could help
just a sec svd2002
0
 
BobSamonikAuthor Commented:
thats what I needed svd2002
I tried with IsNothing but there is no function like that , then I treid
if MyObject=Nothing ... but that did not work eather
thanks everybody
0
 
BobSamonikAuthor Commented:
thats what I needed svd2002
I tried with IsNothing but there is no function like that , then I treid
if MyObject=Nothing ... but that did not work eather
thanks everybody
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.