VB.net error in class code

Murray Brown
Murray Brown used Ask the Experts™
Hi. I am getting an error in the code at the bottom as a result of the code at the top calling it


        For j = 0 To DGV_J.RowCount - 1

            oCellJoin1 = DGV_J.Rows(j).Cells(1).Value
            oCellJoin2 = DGV_J.Rows(j).Cells(2).Value
            'Assign some property values.
            objClass.JointTables = oCellJoin1
            objClass.JointTables = oCellJoin2


Public Class Class1

  Private _pJoinTables As String

    Property JointTables() As String
            Return _pJoinTables
        End Get
        Set(ByVal sValue As String)
            If (Not _pJoinTables.Contains(sValue)) Then
                _pJoinTables = _pJoinTables & "," & sValue 'Error on this line first &
            End If
        End Set
    End Property

End Class
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2015
You are calling the method Contains on a null value. You could set an initial empty value for the string to eliminate the error.

Private _pJoinTables As String = String.Empty

This does not address the reason why the value is null if you were expecting it to be filled.
Murray BrownASP.net/VBA/VSTO Developer


thanks very much

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial