i have an issue with dynamic arrays being passed to class byVal instead byRef, so simplified class, cArray
Option Explicit
Private mArray() As String
Public Sub init(ByRef iArray() As String)
mArray = iArray
End Sub
Public Property Get count() As Long
count = UBound(mArray) - LBound(mArray)
End Property
Public Property Get item(iIndex As Long) As String
item = mArray(iIndex)
End Property
and simple function in module
Private Sub arrTest()
Dim arr() As String, cont As cArray
ReDim arr(0 To 1)
arr(0) = "value0"
arr(1) = "value1"
Set cont = New cArray
cont.init arr
arr(1) = "newValue1"
Debug.Print cont.item(1), arr(1) 'will print value1, newValue1 even though is expected to be same
ReDim Preserve arr(0 To 2)
arr(2) = "value2"
Debug.Print cont.count 'will print 1
End Sub
so, question is, is this bug? normal behavior? something else?