vba 操作txt的问题

来源:百度知道 编辑:UC知道 时间:2024/05/24 10:16:49
在一个TXT文本文档中,有许多行规则且唯一的数据.
现在有几个参数,我想查询在这个文件中包含了所有几个参数的行,
这几个参数可以确定这个行的唯一性.

该如何实现呢?
1L 你的意思我看不大明白,能否稍微解释下

再有就是我需要的一次就比较出里面是否存在我所要查找的内容,而不是一条条的内容输入.

fyi, VBS
'find relation string line of destination file to new file
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f1,f2, ts,n1,n2,nf,da,str
Set fso = CreateObject("Scripting.FileSystemObject")
d1=inputbox("Please input the destination file full name") ' change here for actual condition
str=inputbox("Please input the string need find")' change here for actual condition
d2=left(d1,len(d1)-4) & "_new" & right(d1,4)
fso.CreateTextFile d2
Set f1 = fso.GetFile(d1)
Set ts = f1.OpenAsTextStream(ForReading, TristateUseDefault)
set f2 = fso.Getfile(d2)
Set nf= f2.OpenAsTextStream(ForWriting, TristateUseDefault)
'da=ts.ReadLine
'nf.writeline da
Do While ts.AtEndOfStream <> True
da = ts.ReadLine
if instr(1,da,str)>0 and len(da)>5 then ' change here for actual co