我是VB6编程的新手。我正在尝试从包含我想要的字符串的整个文本文件中加载一行。
1 abc
2 def
4 ghi
5 klm
6 opq
如果我要找的单词是'klm',我希望我的字符串中的整行'5 klm'。我怎么能得到它?
答案 0 :(得分:2)
假设您在变量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