Click to See Complete Forum and Search --> : Object References


DLARLICK
March 13th, 2001, 01:41 PM
I have been trying to add an edit into a program
to check if an object has a valid reference to
another object. I not come up with a viable way
to do this and will have to rework a signficant
amount of logic to handle this.

I tried several IS*** functions. The closest
looking function that may handle this seems to be
the ISOBJECT function. However the object is a
reference to mdiChild forms and must be
dimensioned as a public variable.

MSDN has always helpful hints telling you what
the function will not do. (see below) Using an
error handler to perform this seems quite akward.

IsObject returns True even if the variable has been set to Nothing.

Use error trapping to be sure that an object reference is valid.

Any suggestions would be welcome.

-David

Johnny101
March 13th, 2001, 02:54 PM
Maybe try testing for nothing, then use the TypeName function or the TypeOf Keyword.

If Not objMyObject is nothing then
If TypeOf objMyObject is Form then
Select Case objMyObject.Name
Case "mdiMain"
'do something
Case "frmChild"
'do something else
End Select
End If
End If




something like that?

John


John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org