-
I am creating a program to save data to a sequential access file and I am able to write data to the file using multiple textboxes. When I save the data to the file, one line of
text constitutes one record.
How can I open that file and perform a search for a value, then when it is found, populate the corresponding textboxes?
Any help is much appreciated!
-
<?>
Code:
'search for a particular line and do something with it
'read the file into an array and then back into your file
'and save it
Option Explicit
Option Compare Text
Private Sub Form_Load()
Dim myLine As String
Dim myComp As String
Dim intNum As Integer
myComp = "The line I am Looking for"
intNum = FreeFile
'
'open file
Open "C:\myfile.txt" For Input As intNum
Do While Not EOF(intNum)
Line Input #intNum, myLine
If Trim(myLine) = Trim(myComp) Then
' a match is found
'do whatever your want to do here
text1.Text = myLine 'send the line to a textbox
End If
Loop
Close #intNum
End Sub