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

J

JL

Hi all,

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

Thanks a lot
 
K

Kevin Spencer

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.
 
J

JL

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.
 
N

Nick

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top