Useing a class in a win app

TyB

Well-known member
Joined
May 14, 2009
Messages
102
Programming Experience
3-5
Hello,
I am creating a win app that uses a class. Every time I try to fill a property or read a property of the class I am getting an error that there no instance of the object.

I have a web app that I am also building that I have dozens of classes in and have no problems what so ever so I am at a loss as to what the issue is. Here is my code.

VB.NET:
Public Class clsdups
    Private mintid As List(Of Integer)
    Private mstrname As List(Of String)
    Private mstrpath As List(Of String)
    Private mstrhash As List(Of String)

    Property id() As List(Of Integer)
        Get
            Return mintid
        End Get
        Set(ByVal value As List(Of Integer))
            mintid.Add(value.Item(0))
        End Set
    End Property

    Property name() As List(Of String)
        Get
            Return mstrname
        End Get
        Set(ByVal value As List(Of String))
            mstrname.Add(value.Item(0))
        End Set
    End Property

    Property path() As List(Of String)
        Get
            Return mstrpath
        End Get
        Set(ByVal value As List(Of String))
            mstrpath.Add(value.Item(0))
        End Set
    End Property

    Property hash() As List(Of String)
        Get
            Return mstrhash
        End Get
        Set(ByVal value As List(Of String))
            mstrhash.Add(value.Item(0))
        End Set
    End Property
End Class

Here is the code to read a property that errors.

VB.NET:
Dim objdupfiles As New clsdups

        Dim strname As String = objdupfiles.name(0).ToString

Thanks for any help,

Ty
 
Figured it out.

I finally figured out what the issue was.

I had to add the new keyword to the variable declarations in the class like so.

VB.NET:
    Private mintid As New List(Of Integer)
    Private mstrname As New List(Of String)
    Private mstrpath As New List(Of String)
    Private mstrhash As New List(Of String)

Thanks,

Ty
 
Back
Top