I'm getting an error when trying to read a .txt file into an array for processing. The error and a snippet of the code are below.
Run-time error '9'
Subscript out of range
Dim iFileNum As String
Dim strLineInfo()
Dim i As Integer
Dim strExpensesFile As String
strExpensesFile = "c:\Finance\ExpensesIn.Txt"
iFileNum = FreeFile()
Open strExpensesFile For Input As iFileNum
Do While Not EOF(iFileNum)
Line Input #iFileNum, sBuf
strLineInfo(i) = sBuf
MsgBox strLineInfo(i)
Loop
Close iFileNum
Run-time error '9'
Subscript out of range
Dim iFileNum As String
Dim strLineInfo()
Dim i As Integer
Dim strExpensesFile As String
strExpensesFile = "c:\Finance\ExpensesIn.Txt"
iFileNum = FreeFile()
Open strExpensesFile For Input As iFileNum
Do While Not EOF(iFileNum)
Line Input #iFileNum, sBuf
strLineInfo(i) = sBuf
MsgBox strLineInfo(i)
Loop
Close iFileNum