I think you need to loop when you get to a START and exit it when you get to a STOP. Also this code caters for the specific text you specified at the begining of the thread. You can change it to the name of a variable and pass values of your choice into.
Code:Dim iInput As Integer Dim iOutput As Integer Dim sLine As String iInput = FreeFile Open "c:\sample.txt" For Input As #iInput iOutput = FreeFile Open "c:\sampleout.txt" For Output As #iOutput Do Until EOF(iInput) Line Input #iInput, sLine If InStr(sLine, "START 129, S") Then Do While Not EOF(iInput) Line Input #iInput, sLine If InStr(sLine, "STOP") Then Exit Do Else Print #iOutput, sLine End If Loop End If Loop Close #iInput Close #iOutput![]()




Reply With Quote