Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 16044

Class with collection of classes

$
0
0
First time I have ever posted here so please bear with me. I have a class with a collection of classes in it;

Code:

Public Class clsTViewActions

    'created 28/05/2020

    Public valTViewActions As String 'Process root items
    Public colTViewActionList As List(Of clsTViewActionComment)

    Public Property proTViewActions() As String
        Get
            Return Me.valTViewActions
        End Get
        Set(ByVal value As String)
            If Not (value = valTViewActions) Then
                Me.valTViewActions = value
            End If
        End Set
    End Property

    Public Property proTViewActionListCol() As List(Of clsTViewActionComment)
        Get
            Return Me.colTViewActionList
        End Get
        Set(ByVal value As List(Of clsTViewActionComment))

        End Set
    End Property

End Class

When I use this;

Code:

TViewActionComment = New clsTViewActionComment
        TViewActionComment.proTViewActionComment = "Level 1"

        TViewActions = New clsTViewActions
        TViewActions.proTViewActions = "Level 2"
        TViewActions.proTViewActionListCol = New List(Of clsTViewActionComment)
        TViewActions.proTViewActionListCol.Add(TViewActionComment)

I get the error "System.NullReferenceException: 'Object reference not set to an instance of an object.' MEP_Construction_Process_Tool.clsTViewActions.get_proTViewActionListCol returned Nothing." on the last line.

I am obviously doing something wrong and have searched for an answer but cannot find one.

What am I doing wrong?

Viewing all articles
Browse latest Browse all 16044

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>