checking if instatiated

T

The Other Mike

In my existing Powerbuilder application I have several statements that check
to make sure an object is instatiated.

ie. If isvalid(form1) then....

Is there a way to check for this in VB.NET? I have pasted the definition of
IsValid from Powerbuilder.

I appologize for being such a newbie.

IsValid PowerScript function

Description
Determines whether an object variable is instantiated-whether its value is a
valid object handle.
Syntax
IsValid ( objectvariable )
Argument Description
objectvariable An object variable or a variable of type Any-typically a
reference to an object that you are testing for validity

Return value
Boolean. Returns true if objectvariable is an instantiated object. Returns
false if objectvariable is not an object, or if it is an object that is not
instantiated. If objectvariable is null, IsValid returns null.

Usage

Use IsValid instead of the Handle function to determine whether a window is
open.
 
A

Armin Zingler

The Other Mike said:
In my existing Powerbuilder application I have several statements
that check to make sure an object is instatiated.


Every object is instantiated. Otherwise there wouldn't be an object. The
object is an instance of a type.

Maybe you want to check whether a variable points to an object. This is only
possible with reference types:

dim f as form1


if f is nothing then
msgbox "f does not point to an object"
else
msgbox "f points to an object"
end if


Armin
 
T

The Other Mike

You both were correct. It works great.

Thanks

Armin Zingler said:
Every object is instantiated. Otherwise there wouldn't be an object. The
object is an instance of a type.

Maybe you want to check whether a variable points to an object. This is
only possible with reference types:

dim f as form1


if f is nothing then
msgbox "f does not point to an object"
else
msgbox "f points to an object"
end if


Armin
 

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

Top