LethPhaos
Jan 25, 2007, 09:09 AM
I have the following object:
Public Class clsPath
Private strPath As String
Private strAlias As String
Public Property Path() As String
Get
Return strPath
End Get
Set(ByVal Path As String)
strPath = Path.ToString
End Set
End Property
Public Property PathAlias() As String
Get
Return strAlias
End Get
Set(ByVal PathAlias As String)
strAlias = PathAlias.ToString
End Set
End Property
Public Overrides Function ToString() As String
Select Case -1 'true
Case strAlias = ""
Return strPath
Case Else
Return strPath & " (" & strAlias & ")"
End Select
End Function
End Class
If I want to declare it I would do:
Dim paths() As clsPath
Now to start adding elements I would do:
Dim temp As New clsPath
temp.Path = add.Path
temp.PathAlias = add.PathAlias
ReDim Preserve paths(paths.GetUpperBound(0) + 1)
paths(paths.GetUpperBound(0)) = temp
(add is a custom dialog, both properties return a string from a textbox)
But I get following error:
System.NullReferenceException was unhandled
Object reference not set to an instance of an object.
So I guess I'm doing something wrong.
Could anyone help me out?
Thanks!
EDIT: typo fixed
Public Class clsPath
Private strPath As String
Private strAlias As String
Public Property Path() As String
Get
Return strPath
End Get
Set(ByVal Path As String)
strPath = Path.ToString
End Set
End Property
Public Property PathAlias() As String
Get
Return strAlias
End Get
Set(ByVal PathAlias As String)
strAlias = PathAlias.ToString
End Set
End Property
Public Overrides Function ToString() As String
Select Case -1 'true
Case strAlias = ""
Return strPath
Case Else
Return strPath & " (" & strAlias & ")"
End Select
End Function
End Class
If I want to declare it I would do:
Dim paths() As clsPath
Now to start adding elements I would do:
Dim temp As New clsPath
temp.Path = add.Path
temp.PathAlias = add.PathAlias
ReDim Preserve paths(paths.GetUpperBound(0) + 1)
paths(paths.GetUpperBound(0)) = temp
(add is a custom dialog, both properties return a string from a textbox)
But I get following error:
System.NullReferenceException was unhandled
Object reference not set to an instance of an object.
So I guess I'm doing something wrong.
Could anyone help me out?
Thanks!
EDIT: typo fixed