CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2000
    Location
    Pennsylvania, United States
    Posts
    106

    Object References

    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



  2. #2
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: Object References

    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
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured