Reputation: 25
I am new to VB6 programming. I am trying to load a line from the whole text file that contains the string that I want.
1 abc
2 def
4 ghi
5 klm
6 opq
If my word to find is 'klm', I want the whole line '5 klm' in my string. How can I get it?
Upvotes: 2
Views: 5623
Reputation: 2079
Assuming you have the filename in a variable sFileName:
Dim iFile as Integer
Dim sLine as String, sNewText as string
iFile = FreeFile
Open "C:\Folder\replacewithpath\db.txt" For Input As #iFile
Do While Not EOF(iFile)
Line Input #iFile, sLine
If sLine Like "*klm*" Then
'sLine has got the line , use
End If
Loop
Close
Upvotes: 1