Link to home
Start Free TrialLog in
Avatar of MrKevorkian
MrKevorkian

asked on

how check if an object is set to an instance

hello

i keep getting object not set to an instance

when i check if an object (MyObject.OrganisationDetails.ContactDetails.Telephones(0)) exists:

i tried:
            If Not IsDBNull(MyObject.OrganisationDetails.ContactDetails.Telephones(0)) Then
            If Not (MyObject.OrganisationDetails.ContactDetails.Telephones(0)) is nothing Then

but both return that same error.

how do i check an object that may not exist - to see if it does exist






ASKER CERTIFIED SOLUTION
Avatar of fds_fatboy
fds_fatboy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MrKevorkian
MrKevorkian

ASKER

perfect.


public function HasTelephoneNumber as boolean
        Try
             if MyObject.OrganisationDetails.ContactDetails.Telephones.Count > 0 then
                 Return True
             end if
        Catch ex As NullReferenceException
             return False
        End Try
end function


KGreg