Getting the proverbial "Object reference not set to an instance of an object" error?

I've created a class that inherits the System.Windows.Forms.TabPage class. I'm not sure how to declare an instance of the class. There needs to be an instance for each TabPage created on a specific TabControl. I basically set this new property in the "SelectedIndexChanged()" Event. I'm getting Object Reference error because I'm not sure how to declare the variable.

New Class
Public Class tabPageViewed
    Inherits System.Windows.Forms.TabPage

    Private _viewed As Boolean

    Property TabViewed() As Boolean
            TabViewed = _viewed
        End Get
        Set(value As Boolean)
            _viewed = value
        End Set
    End Property

End Class

Open in new window

What is the difference in the two statements below?

'Statement 1
     Private tabV() As tabPageViewed

'Statement 2
     Private tabV As New tabPageViewed()

Open in new window

How should it be declare with regard to the context in which I'm using it. I only set and check this property in the "SelectedIndexChanged()" Event.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BlakeMcKennaAuthor Commented:
Here is how I'm using the class

    Private Sub tabChannelTestLoad_SelectedIndexChanged(sender As Object, e As EventArgs) Handles tabChannelTestLoad.SelectedIndexChanged
            EH.ErrorMessage = String.Empty

            idx = tabChannelTestLoad.SelectedIndex

            If tabChannelTestLoad.SelectedIndex <> -1 And Not clsTabViewed.TabViewed Then
                clsTabViewed.TabViewed = True

                Perform various functions...

            End If


        Catch ex As Exception
            EH.ErrorMessage = "frmCalibration_3/tabChannelTestLoad_SelectedIndexChanged() - " & ex.Message & "...Contact Engineering!" & "~E"
        End Try

        EH.ProcessMessages(Me, sbr, EH.ErrorMessage)
    End Sub

Open in new window

käµfm³d 👽Commented:
What is the difference in the two statements below?
The first line declares an uninitialized array of tabPageViewed. The second declares and instantiates a new tabPageViewed object.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BlakeMcKennaAuthor Commented:
How should I declare it with reference to how I'm using it?

See post 40881158!
BlakeMcKennaAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.