VB有没有办法搜寻某一个TXT档里面是否有123这个档名的档案

来源:百度知道 编辑:UC知道 时间:2024/06/28 07:33:53
如题
有没有办法直接利用VB
搜寻某一个TXT档里面是否有内含有"123"这三个文字
或是说
有没有办法用写的程式控制开启TXT档后
自己从编辑搜寻"123"这个

Private Sub Command1_Click()
dim x(10000) as string
Open "C:\1.TXT" for input as #1
For i=0 to 10000
if not eof(1) then
input #1,x(i)
if instr(x(i),"123")>0 then Print "123存在于第" & i & "行。"
else
J=i
exit for
end if
next
Close #1
End Sub
以上程序就可以搞定

Private Sub Command1_Click()
Dim tmpStr As String
Dim FindStr As String
FindStr = "123"
Open "c:\test.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, tmpStr
If InStr(1, tmpStr, FindStr, vbBinaryCompare) Then MsgBox "找到了" & FindStr
Loop
Close #1
End Sub