Solved

how check if an object is set to an instance

Posted on 2004-09-24
3
188 Views
Last Modified: 2010-04-23
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






0
Comment
Question by:MrKevorkian
3 Comments
 
LVL 10

Accepted Solution

by:
fds_fatboy earned 250 total points
ID: 12143660
Do you mean like this?

Dim bExists As Boolean = False

If Not MyObject Is Nothing Then
    If Not MyObject.OrganisationDetails Is Nothing Then
        If Not MyObject.OrganisationDetails.ContactDetails Is Nothing Then
            If Not MyObject.OrganisationDetails.ContactDetails.Telephones(0) Is Nothing Then
                bExists = True
            End If
        End If
    End If
End If

If bExists Then...
0
 
LVL 1

Author Comment

by:MrKevorkian
ID: 12144940
perfect.

0
 
LVL 6

Expert Comment

by:KGreg
ID: 12144955

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
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now