Hi There,
I hope someone can help me.
I'm trying to figure out how to loop trough 2 TXT file to search a number and then again and again.
But the problem is that the loop does not loop.....
The search in the TXT file just continues where it left of and I can't figure out how to reset this.
I'm trying to let the TXT file be left open [OPEN FOR INPUT] because I think opening and closing takes up precious time when searching for 500 or so different numbers.
Anyone any ideas?
Here a scrap of the code with the loop.
<code>
' A loop for every numbers in the list
For R = 1 To UBound(Arr, 1)
'Loop until the end of file
Do While Not EOF(intFNumber)
MsgBox Arr(R, 1)
'Read data from file
Line Input #intFNumber, sLine
If InStr(1, Mid(sLine, 1, 9), Arr(R, 1), vbTextCompare) Then
GLN = Mid(sLine, 153, 33)
MsgBox GLN, vbInformation, "GLNfabrikant + Prod.code fabrikant"
Do While Not EOF(intFNumber2)
'Read data from file
Line Input #intFNumber2, sLine2
If InStr(1, Mid(sLine2, 153, 33), GLN, vbTextCompare) Then
MsgBox (Mid(sLine2, 2, 9)), vbInformation, "TU nummer"
End If
Exit Do
Loop
End If
Exit Do
Loop
Next
'Close the file
Close #intFNumber
Close #intFNumber2
</code.
I hope someone can help me.
I'm trying to figure out how to loop trough 2 TXT file to search a number and then again and again.
But the problem is that the loop does not loop.....
The search in the TXT file just continues where it left of and I can't figure out how to reset this.
I'm trying to let the TXT file be left open [OPEN FOR INPUT] because I think opening and closing takes up precious time when searching for 500 or so different numbers.
Anyone any ideas?
Here a scrap of the code with the loop.
<code>
' A loop for every numbers in the list
For R = 1 To UBound(Arr, 1)
'Loop until the end of file
Do While Not EOF(intFNumber)
MsgBox Arr(R, 1)
'Read data from file
Line Input #intFNumber, sLine
If InStr(1, Mid(sLine, 1, 9), Arr(R, 1), vbTextCompare) Then
GLN = Mid(sLine, 153, 33)
MsgBox GLN, vbInformation, "GLNfabrikant + Prod.code fabrikant"
Do While Not EOF(intFNumber2)
'Read data from file
Line Input #intFNumber2, sLine2
If InStr(1, Mid(sLine2, 153, 33), GLN, vbTextCompare) Then
MsgBox (Mid(sLine2, 2, 9)), vbInformation, "TU nummer"
End If
Exit Do
Loop
End If
Exit Do
Loop
Next
'Close the file
Close #intFNumber
Close #intFNumber2
</code.