|
zh159
金牌会员
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第
16 楼』:
Set fso = CreateObject("Scripting.FileSystemObject")
source = "a.txt"
strFind = "a,b,c,d,e,f"
strFind = Split(strFind,",")
Num = Ubound(strFind)
Set f = fso.OpenTextFile(source,1)
While not f.AtEndOfStream
strRead = f.ReadLine
For i = 0 to Num
If instr(strRead,strFind(i))>0 Then
msgbox strRead
End If
Next
Wend
f.Close 这里查找的字符区分大小写(执行的是二进制比较,具体查看instr用法)
[ Last edited by zh159 on 2007-12-16 at 02:46 PM ]
|
|
|
2007-12-16 14:44 |
|
|
lotus516
高级用户
论坛上抢劫的
积分 551
发帖 246
注册 2006-9-21
状态 离线
|
『第
17 楼』:
Quote: | Originally posted by zh159 at 2007-12-16 14:44:
[code]Set fso = CreateObject("Scripting.FileSystemObject")
source = "a.txt"
strFind = "a,b,c,d,e,f"
strFind = Split(strFind,",")
Num = Ubound(strFind)
... |
|
zh159理解错我的意思了,我是说strFind的值从某一个文本中取得,不是后面跟一串,总不可能我要找50个,strFind后面打上50个变量吧!!
|
|
2007-12-17 08:12 |
|
|
zh159
金牌会员
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第
18 楼』:
Quote: | Originally posted by lotus516 at 2007-12-17 08:12:
zh159理解错我的意思了,我是说strFind的值从某一个文本中取得,不是后面跟一串,总不可能我要找50个,strFind后面打上50个变量吧!! |
|
Set fso = CreateObject("Scripting.FileSystemObject")
source = "a.txt"
target = "b.txt"
Set f = fso.OpenTextFile(source,1)
strFind = f.ReadAll
f.Close
Set f = fso.OpenTextFile(target,1)
While not f.AtEndOfStream
strRead = f.ReadLine
If instr(1,strFind,strRead,1)=0 Then
str = str & strRead & vbCrLf
End If
Wend
f.Close
msgbox str
|
|
|
2007-12-17 10:06 |
|
|