VB源码(文件读写)

来源:百度知道 编辑:UC知道 时间:2024/05/27 21:02:09
我要求写一个VB程序:在一个多行的文本中查找一个字符串,如果此行有字符串,将此行记录到另外一个文件中。谢谢大家

Private Sub Command1_Click()
Dim s As String, a As String
Open "d:\old.txt" For Input As #1
Open "d:\new.txt" For Output As #2

a = "1234" '要找的字符串

Do While Not EOF(1)
Line Input #1, s
If InStr(s, a) > 0 Then Print #2, s
Loop
Close #1
Close #2
End Sub