option explicit '严格语法
dim found,fso,file,str
set fso=createobject("scripting.filesystemobject") '创建文件系统对象
set file=fso.opentextfile("test.txt") '打开文件,并得到文件对象
found = "" '初始化缓冲区
while not file.atendofstream '只要文件没有结束就循环
str = file.readline '读取一行内容
if instr(str,"3")>0 then '判断是否包含3
found = found & str & vbcrlf '如果包含就加入到缓冲区
end if
wend
file.close '关闭文件
msgbox found '显示结果
set fso = nothing'释放对象
set file = nothing '(不知道这句该加么?)