Open "c:\a.txt" For Input As #1
Do While Not EOF(1)
n = n + 1
ReDim Preserve MyStr1(n)
Line Input #1, MyStr1(n)
Loop
Close #1
Open "c:\b.txt" For Input As #1
open "c:\~c.txt" For output As #2
Do While Not EOF(1)
line input #1,TmpS '读一行
if len(tmps)>3 then '如果超过3字符则继续处理。用于容错,如果3改成0,那就只判断空行。
isyn = false '默认不存在
tmps1=left(tmps,4) '固定长度用这个
'tmps1=left(tmps,instr(1,tmps," ")) '不固定长度用这个
for i=1 to ubound(mystr1()) '查找循环
if tmps1=mystr1(i) then '找到
isyn=true
exit for
end if
next i
if isyn then '是否找到,找到则将写入,否则忽略,就会丢弃该行。
print #2,tmps
end if
else '空行,及小于3字符的内容原样写入,自己决定。
print #2,tmps
end if
Loop
close #2
Close #1
kill "c:\b.txt" '删原文件,
name "c:\~c.txt","c:\b.txt" '改名。调试时,不要用这二行。会破坏原文件,导致调试无法进行。
-------------------------------