I assume this should be an easy question to answer, but I'm not too experienced with classes so it's far from obvious to me.
What's wrong with the class code below, namely the Let x property? An error message warns that an object is required. After adding items to the collection, at a certain stage I want to modify one of them. How should I go about it?
What's wrong with the class code below, namely the Let x property? An error message warns that an object is required. After adding items to the collection, at a certain stage I want to modify one of them. How should I go about it?
Code:
Option Explicit
Private mcol As Collection
Private Sub Class_Initialize()
Set mcol = New Collection
End Sub
Private Sub Class_Terminate()
Set mcol = Nothing
End Sub
Public Property Get Count() As Integer
Count = mcol.Count
End Property
Public Sub AddItem(ByRef x As Single)
mcol.Add x
End Sub
Public Property Get x(ByRef index As Integer) As Single
x = mcol.Item(index)
End Property
Public Property Let x(ByRef index As Integer, ByVal x As Single)
mcol.Item(index) = x
End Property