Creating an array of arrays of data objects?
I have a data object
I also have arrays of these data objects
I want to put these arrays of data objects into another array
Dim ArrayOfDataObjects1(10) as new DataObject
Dim ArrayOfDataObjects2(10) as new DataObject
Dim ArrayOfDataO开发者_如何学JAVAbjects3(10) as new DataObject
'Now, I want to put all of these into another array, how can I?
Thanks!
edit: I know I need to create another array with size 3, but what type do I define the array as?
If you are not concerned with type-safety, you could use Variant. Example in Excel VBA:
Sub a()
Dim ArrayOfDataObjects1(10) As Worksheet
Dim ArrayOfDataObjects2(10) As Worksheet
Dim ArrayOfDataObjects3(10) As Worksheet
Dim arr(3) As Variant
Set ArrayOfDataObjects1(1) = ActiveSheet
arr(1) = ArrayOfDataObjects1
arr(2) = ArrayOfDataObjects2
arr(3) = ArrayOfDataObjects3
MsgBox arr(1)(1).Name
End Sub
精彩评论