-
I can't get this to work. I need to dynamically add to a two dimension array. Where am I going wrong? It goes through a loop and the second time it adds a column it give me a subscript out of range.
Thanks
Code:
Dim sDocInfo() As String
Dim iDocInfo As Integer
ReDim Preserve aDocInfo(iDocInfo, 2)
aDocInfo(iDocInfo, 1) = "info"
aDocInfo(iDocInfo, 2) = "info2"
iDocInfo = iDocInfo + 1
-
You can resize only last dimantion of your array.
Example:
Code:
Dim arrMyArray()
Redim Preserve arrMyArray(5, 2)
Redim Preserve arrMyArray(5, 10) 'This will add 8 more elements
------------------
Serge
Senior Programmer Analyst
[email protected]
[email protected]
ICQ#: 51055819
-
-
Let me modify what Serge said a little. You can only resize the last dimension of your array when you specify Preserve. If you remove Preserve your code would not give you an error, but that may not be what you want to do,
------------------
Marty
HASTE CUISINE
Fast French food.
-
That's right!
Because of this I had to use a 1D-array for my map (tile-based game) so I could resize it.
(You just have to calculate the 'real' position in the array... not much work)
------------------
[email protected]
...
Every program can be reduced to one instruction which doesn't work.