I have tried to implement this several different ways and am obviously missing something.
Class CUnit which includes an array of CPanel objects -
Private pPanel() As CPanel
Public Property Get Panel(Optional RIndex As Integer) As CPanel
If RIndex = 0 Then
Panel = pPanel
Else
Panel = pPanel(RIndex)
End If
End Property
Public Property Let Panel(Optional RIndex As Integer, Value As Variant)
If RIndex = 0 Then
pPanel = Value
Else
pPanel(RIndex) = Value
End If
End Property
Body of module:
Function UnitBom(Unit As CUnit) As CUnit
Set UnitBom = Unit
Dim Panels() As CPanel
ReDim Panels(1 To UnitBom.NumPanels)
Dim PanelTemp As CPanel
Set PanelTemp = New CPanel
Dim i As Variant
For i = 1 To UnitBom.NumPanels
Set Panels(i) = PanelTemp
Next i
UnitBom.Panel = Panels()
this works
Panels(1).Width = 1
When I run this I get "Object variable or with block variable not set."
UnitBom.Panel(1).Width = 2
You guys will have to forgive me because I have obviously not explained very well. I need an array of CPanel objects inside a CUnit object. The problem is that when I create the CUnit object, I dont know how big to make the CPanel array. I was attempting to create a temporary array that is the proper size as soon as I know what that size should be and then set the CUnit array equal to the temporary array in order to "size" it. There is probably a far better way of accomplishing the same thing.