我正在尝试使用Double()数组数组创建一个锯齿状数组。我只是想动态地将这个a()Double添加到d()中。当我尝试从d中拉出一个副本并将其放入x时出现错误。
Sub Test3()
Dim a() As Double, i As Integer
ReDim a(1 To 10, 1 To 3)
a(1, 2) = 3.5
Dim d() As Variant
For i = 1 To 3
ReDim Preserve d(1 To i)
d(i) = Array(a)
Next i
Dim x() As Double
x = d(1) ' Error, Type Mismatch
MsgBox (x(1, 2))
End Sub
答案 0 :(得分:1)
试试这个。将数组(a)更改为a。
Sub Test3()
Dim a() As Double, i As Integer
ReDim a(1 To 10, 1 To 3)
a(1, 2) = 3.5
Dim d() As Variant
For i = 1 To 3
ReDim Preserve d(1 To i)
d(i) = a
Next i
Dim x() As Double
x = d(1) ' Error, Type Mismatch
MsgBox (x(1, 2))
End Sub