Populating collection with arrays

前端 未结 5 1208
忘掉有多难
忘掉有多难 2021-01-11 12:03
Dim A As Collection
Set A = New Collection

Dim Arr2(15, 5)
Arr2(1,1) = 0
\' ...

A.Add (Arr2)

How can I access the Arr2 through

5条回答
  •  半阙折子戏
    2021-01-11 12:52

    Maybe VBA makes a copy of the array when it assigns it to the collection? VB.net does not do this. After this code, a(3,3) is 20 in vba and 5 in vb.net.

    Dim c As New Collection
    Dim a(10, 10) As Integer
    
    a(3, 3) = 20
    c.Add(a)
    c(1)(3, 3) = 5
    

提交回复
热议问题