Easy...just test the values immediately after you do each read. Stop reading when you find what you're looking for. Here's a code snippet to get you started:
Dim intId As Integer
Dim strname As String
Dim strAddress As String
Dim strBirthDate As String
Dim strPayrollType As String
Open App.Path & "\FileReadingFun.txt" For Input As 1
If Not EOF(1) Then
Do
Input #1, intId, strname, strAddress, strBirthDate, strPayrollType
If intId = 2 Then ' or whatever you test for
Debug.Print CStr(intId); strname; strAddress; strBirthDate; strPayrollType
' or whatever you're going to do with your data
End If
Loop Until EOF(1)
End If
Close #1
Depending on how you open and read your file, you have various options as far as writing changes and such. You'll have to figure that part out yourself. I suggest you spend some time looking at the OPEN statement in the VB Help File.
That being said, I would question your choice of using a regular text file to do this. Have you considered using a DBMS such as MSAccess, mySQL or MSSQL? Or, if that's not an option, how about reading your entire text file into an ADO Recordset object in memory, doing your manipulations there, then write the whole dataset back to a text file when you're done? There are lots of options.
BitBlt
Practically a Posting Shark
894 posts since Feb 2011
Reputation Points: 482
Solved Threads: 148
Skill Endorsements: 14