I have a csv file as such:
hello,world,this
is,an,example,
of,the,csv,file
The first column will always be unique.
I am getting the user to enter a string which matches an item in the first column, and the script returns the whole line:
Open "C:\file1.csv" For Input As #file_number
Do While (EOF(1) Or found = False)
Line Input #file_number, raw_line
pos = InStr(raw_line, fireName)
If pos = Not 0 Then
strData() = Split(raw_line, ",")
found = True
End If
Loop
Close #file_number
If found = False Then
MsgBox "Could not find it"
Exit Sub
End If
'REST OF THE CODE
But it always sends the message "could not find it" and exits. By default, found is a boolean value and is false.
I know it can detect the file as when I changed the read file name, it created a new one (as it does not exist).
EDIT:
I changed the And to an Or and now I get the error:
Run-time error 62: input past end of file
EOF(1)checks a hard-coded file number and you open it as #file_number. It should beEOF(file_number).