F
flaterp
I wish to search for 2 separate strings in one file. I prefer to not follow
this sequence: (1) Open txt file (2) search for first string (3) output
result (4) close txt file (5) repeat 1-4 for second string. I would like to
perform the query without having to close and reopen the txt file. My
current program resembles what it listed below. Obviously my syntax for
"LineofText2" is incorrect, so please offer your suggestions. Is possible to
do something along the lines of "Open fName For Input As #1 and #2"? thanks
in advance.
Open fName For Input As #1
sStr = ""
sStr2 = ""
Do While Not EOF(1)
Line Input #1, LineofText
If (InStr(1, LineofText, "Reboot", vbTextCompare)) Then
sStr = Left(LineofText, 12)
End If
If (InStr(1, LineofText2, "Yes", vbTextCompare)) Then
sStr2 = Mid(LineofText2, 12, 3)
End If
Loop
Cells(iVar, "A").Value = sStr
Cells(iVar, "B").Value = sStr2
Close #1
this sequence: (1) Open txt file (2) search for first string (3) output
result (4) close txt file (5) repeat 1-4 for second string. I would like to
perform the query without having to close and reopen the txt file. My
current program resembles what it listed below. Obviously my syntax for
"LineofText2" is incorrect, so please offer your suggestions. Is possible to
do something along the lines of "Open fName For Input As #1 and #2"? thanks
in advance.
Open fName For Input As #1
sStr = ""
sStr2 = ""
Do While Not EOF(1)
Line Input #1, LineofText
If (InStr(1, LineofText, "Reboot", vbTextCompare)) Then
sStr = Left(LineofText, 12)
End If
If (InStr(1, LineofText2, "Yes", vbTextCompare)) Then
sStr2 = Mid(LineofText2, 12, 3)
End If
Loop
Cells(iVar, "A").Value = sStr
Cells(iVar, "B").Value = sStr2
Close #1