How to check the class variable is "new"(to object) or not?

  • Thread starter Thread starter JL
  • Start date Start date
J

JL

Hi all,

I like to know that how to check the class variable is "New"(to object) or
not?

Thanks a lot
 
Can you rephrase your question? I'm afraid that it may not get answered
because nobody understands what you mean.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Sorry for leading you mis-understanding

My question is if i have class variable like following,
Dim myClass As MyClass

How can i check this variable is instanced or not, e.g.
myClass = New MyClass()

Finally, i found the answer,

If TypeOf (myClass) Is Object
Response.Write("myClass is object")
else
Response.Write("myClass is not object")
end if

Thanks for your reminding.
 
This way is not really the right way to do it, because anythign is always
going to be an object but you need to check to see if it has been set to
Nothing is what your asking. The following way is wrong for what I
understand from you message

If TypeOf (myClass) Is Object
Response.Write("myClass is object")
else
Response.Write("myClass is not object")
end if

try this way

If myClass Is Nothing
Response.Write("myClass not set")
Else
Response.Write("myClass is set")
End If
 
Back
Top