|
-
Feb 3rd, 2000, 05:08 AM
#1
Thread Starter
Member
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
-
Feb 3rd, 2000, 05:52 AM
#2
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
-
Feb 3rd, 2000, 05:55 AM
#3
Thread Starter
Member
-
Feb 3rd, 2000, 06:41 AM
#4
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.
-
Feb 3rd, 2000, 07:16 AM
#5
PowerPoster
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|