Nope. You'd have to OVERLOAD the CONSTRUCTOR to set up the class with zero or more items.
Create a SUB inside of the class (and make it PUBLIC) so you can call it. Pass the parameters, then REDIM / Preserve or not the Array. Might need more for different array types
Sorry if I mingle, but where is the problem? VB knows dynamic arrays. If I may make you recall the proper syntax:
Code:
Dim MyArray() as String, x%, y%
...
'now we get the dimensions
x=4
y=5
ReDim MyArray(x, y)
You cannot use variables in a Dim statement. Only constants are allowed.
Dim A() however makes a dynamic array, which gets its final dimensining with th ReDim statement, which allows the use of variables.
David: An interesting thesis. Which constructor of which class would you like to overload?
Btw.:
Dynamic Arrays can certainly be passed byref to a function/sub to be dimensioned there.
Code:
Dim arr$()
Private Sub DimArray(AnArray() As String)
Dim x%, y%
x = 3
y = 7 * 5
ReDim AnArray(x, y)
End Sub
Private Sub Command1_Click()
DimArray arr
End Sub
I think that should completely cover your problem, jwspring.
Oh, not to forget: ReDim Preserve allows to increase the array elements while keeping the existing content. Only I think you cannot change the number of dimensions anymore.
Bookmarks