Hi,
I have this code to read a text file and populate an array and a 2D array with the values from the file. However it gets stuck in an endless loop. I think it may have something to do with my 2D array declaration, but i'm not sure. It worked perfectly when I had three single arrays instead of the 2D array.
Many Thanks,
Chris
I have this code to read a text file and populate an array and a 2D array with the values from the file. However it gets stuck in an endless loop. I think it may have something to do with my 2D array declaration, but i'm not sure. It worked perfectly when I had three single arrays instead of the 2D array.
Code:
Dim ArrayContract() As Variant 'declare as a variable length array
Dim ArrayPosition() As Variant '2D array
Open "U:/contracts.txt" For Input As #1
k = 0
i = 0
j = 0
On Error Resume Next
Do While Not EOF(1)
ReDim Preserve ArrayContract(k + 1) As Variant 'resize the array to add another place
ReDim Preserve ArrayPosition(i + 1, j + 1) As Variant 'resize the array to add another place
Input #1, ArrayContract(k), ArrayPosition(i, j)
k = k + 1
i = i + 1
j = j + 1
Loop
Close #1
Many Thanks,
Chris