I have created a class with a Private Dynamic Array of String.
I wrote the following class with properties to access the array.
VB Code Code:
Public Class MyClass
Private c_Text As String()
Public Sub New()
ReDim c_Text(0)
End Sub ' New
ReadOnly Property NumText() As Integer
Get
Return UBound(c_Text) + 1
End get
End Property ' NumText
Property Texts(ByVal Index As Integer) As String
Get ' Return Text
If (0 <= Index) And (Index < NumText()) Then
Return c_Text(Index)
Else
Return ""
End If
End Get
Set(ByVal value As String)
If (0 <= Index) And (Index < NumText()) Then
c_Text(Index) = value
Else
ReDim Preserve c_Text(NumText() + 1)
c_Text(NumText()) = value
End If
End Set
End Property ' Texts
End Class ' My Class
My Problem starts when I try to use the Property Texts.
Causes no errors.
However, when I try to use the Set part I get an error message.
Property access must assign to the property or use its value.
In the documentation I have looked at (Various books and MSDN and Online
Help) it clearly indicates that properties can have parameters, and my
declaration of Texts throws up no errors.
But nowhere can I find an example showing a Property with a Parameter List being used.
Can you advise where I am going wrong, and how to correct it please.
So far all the examples I have found on MSDN and VBForums