I want to use a two dimension array to store some contents read in from a tab delimited text file. I don't know how many items I will have until I read to the end of the file, but I do know the columns per line is 2. I've worked with resizing single dimension arrays, but never mulit-dimension.
The way I've done this before with one-dimension arrays is to declare a dynamic array, then resize it as needed.
This fails for a two-dimension array. The first ReDim works, but every subsequent ReDim fails with a "Subscript out of range" error. Here's some example code:
Dim strTest() As String
ReDim Preserve strTest(10, 2) As String
ReDim Preserve strTest(20, 2) As String
Can I only ReDim a multi-dimension array once, or am I missing something here?
As always, suggestions for better ways of reading in my text file are appreciated too.
Thanks in advance
The way I've done this before with one-dimension arrays is to declare a dynamic array, then resize it as needed.
This fails for a two-dimension array. The first ReDim works, but every subsequent ReDim fails with a "Subscript out of range" error. Here's some example code:
Dim strTest() As String
ReDim Preserve strTest(10, 2) As String
ReDim Preserve strTest(20, 2) As String
Can I only ReDim a multi-dimension array once, or am I missing something here?
As always, suggestions for better ways of reading in my text file are appreciated too.
Thanks in advance