声明一组具有动态维度的数组



在VBA中,我想声明一组数组。说 X01, X02, .., X99 每个都有不同的尺寸

我尝试使用暗点 X(1 到 99(。但是,以后似乎很难为每个维度设置维度。

在这种情况下,是否有任何有效的方法来声明数组? 例:

X01: size (5,6)
X02: size (2,3)
X03: size (1,9)
etc

也许...

Option Explicit
Public Sub ArraysOfArrays()
' Option #1 ... individual, explicit definitions
Dim X01(5, 6)
Dim X02(6, 3)
' etc
' Option 2 ... a three dimension array
Dim Y(99, 10, 10)
Y(0, 0, 0) = "A"
Y(1, 5, 6) = "B"
' etc
' Option 3 ... an array of different arrays
Dim Tmp
Dim Z(99)
ReDim Tmp(5, 6): Z(0) = Tmp
ReDim Tmp(6, 3): Z(1) = Tmp
' etc
' Option 4
' ... create a table with three keys in some form of database
' Option 5
' ... use a worksheet, a dictionary or one of the myriad of other options  :)
End Sub

最新更新