I think I have a pretty good handle on how to handle module level arrays in VBA though Property Get and Let. Is there a way to ReDim a module level array through a property?
The following code errors out at the ReDim statement in the last procedure (DoTest).
Private mstrTestArray() As String
Private Sub Class_Initialize()
ReDim mstrTestArray(0) As String
End Sub
Private Property Get TestArray() As String()
TestArray = mstrTestArray
End Property
Private Property Let TestArray(ByRef strTestArray() As String)
mstrTestArray = strTestArray
End Property
Private Property Get TestArrayValue(d1 As Long) As String
TestArrayValue = mstrTestArray(d1)
End Property
Private Property Let TestArrayValue(d1 As Long, strValue As String)
mstrTestArray(d1) = strValue
End Property
Sub DoTest()
Dim intCharCode As Integer
For intCharCode = 97 To 122
If Not Len(TestArrayValue(UBound(TestArray))) > 0 Then
TestArrayValue(UBound(TestArray)) = Chr(intCharCode)
Else
ReDim Preserve TestArray(UBound(TestArray) + 1) As String
TestArrayValue(UBound(TestArray)) = Chr(intCharCode)
End If
Next intCharCode
Debug.Print TestArrayValue(LBound(TestArray)) _
& " through " _
& TestArrayValue(UBound(TestArray))
End Sub
Thanks!