Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • Last Modified:

How to tell if a variable contains an object

I've created a form and stored it in a variable, however i need to be able to tell if the form has already been created and stored so that i don't do it again.

How do i do it? There used to be IsObject in VB6.
0
James_Wyatt
Asked:
James_Wyatt
1 Solution
 
Ravi SinghSenior Software EngineerCommented:
When a variable isnt referencing anything its usually just a null, have you tried comparing against the null?

if (FormObject == null)
      //FormObject not initialised
else
     //FormObject was initialised
0
 
James_WyattAuthor Commented:
Cheers i narrowed it down to

if (myResults == null || myResults.IsDisposed)

had to add is disposed incase someone had closed the form.
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.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now