I just wrote this function to read a series of email addresses from a linebreak-delimited text file. And it does work, but that's not my question.
Function GetEmailArray(FileName As String) As String()
Dim TempArr() As String
Dim i As Integer
Open FileName For Input Access Read As #1
Do While Not (EOF(1))
i = i + 1
ReDim Preserve TempArr(i + 1)
Line Input #1, TempArr(i + 1)
Debug.Print TempArr(i + 1)
Loop
Close #1
GetEmailArray = TempArr
End Function
Reading this, I would expect this to:
- Read the first line, store it in TempArr(1)
- Loop
- Read the first line AGAIN, store it in TempArr(2)
- Loop
- Etc
I just can't figure out how the while loop goes to the next line in the text file.