位置不同了还能叫重复麽?!.......算了....这些数据都表示什么意思?
不过如果我都写出来了,你还用编麽?不如你参考一下9楼的方法(声明:我不懂).
至于我的方法,你可以先选出有用的arr() (譬如把有用的arr()放到一个2维数组arr2(n,2)中),再逐个比较选出的数组,把"重复"的删掉,最后才输出文件.
the end
看不懂你的想法....介绍个论坛
Dim aaa(100, 6), ccc(100) As String
Private Sub Command1_Click()
k = 0
FILE_NAME = App.Path & "/test.txt"
Open FILE_NAME For Input As #1
Do While Not EOF(1)
Line Input #1, org_txt
If k >= 1 And Trim(org_txt) <> "" Then
BK = BK + 1
ccc(BK) = Trim(org_txt)
End If
If Left(Trim(org_txt), 2) = "RP" Then k = 1
Loop
Close #1
For i = 1 To BK
sss = ccc(i)
Do While InStr(sss, " ") <> 0
sss = Replace(sss, " ", " ")
Loop
ccc(i) = sss
Next i
For i = 1 To BK
ppp = Split(ccc(i), " ")
For j = 0 To UBound(ppp)
aaa(i, j) = ppp(j)
Next j
Next i
FILE_NAME = App.Path & "/out.txt"
Open FILE_NAME For Append As #1
For i = 1 To BK
If aaa(i, 6) = "AB" Or aaa(i, 6) = "MB" Or aaa(i, 6) = "CB" Then
Print #1, "bleme:rp=" & aaa(i, 0) & ",rpt=" & aaa(i, 4) & ",em=" & aaa(i, 2)
End If
Next i
Close #1
End Sub
RESULT: out.txt
bleme:rp=12,rpt=13,em=0
bleme:rp=12,rpt=13,em=1
bleme:rp=12,rpt=13,em=2
bleme:rp=13,rpt=12,em=0
bleme:rp=13,rpt=12,em=1
bleme:rp=13,rpt=12,em=2
bleme:rp=32,rpt=33,em=0
bleme:rp=32,rpt=33,em=1
bleme:rp=32,rpt=33,em=2
bleme:rp=32,rpt=33,em=3
bleme:rp=32,rpt=33,em=10
bleme:rp=33,rpt=32,em=0
bleme:rp=33,rpt=32,em=1
bleme:rp=33,rpt=32,em=2
bleme:rp=33,rpt=32,em=3
bleme:rp=33,rpt=32,em=10
bleme:rp=384,rpt=385,em=8
bleme:rp=384,rpt=385,em=10
bleme:rp=385,rpt=384,em=8
bleme:rp=385,rpt=384,em=10
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
但有个问题:输出文件中相关的都有重复啊,怎么把重复的屏蔽掉,可以通过删除重复的或在重复的前面加“!” 也可以,因为最终我要把OUT.TXT 再传到机器里运行,而机器是基于C语言的所以在前面加“!”的行不执行!~ 请高手再赐教一下如何实现啊?
也就是最终输出结果为:
RESULT: out.txt
bleme:rp=12,rpt=13,em=0;
bleme:rp=12,rpt=13,em=1;
bleme:rp=12,rpt=13,em=2;
bleme:rp=32,rpt=33,em=0;
bleme:rp=32,rpt=33,em=1;
bleme:rp=32,rpt=33,em=2;
bleme:rp=32,rpt=33,em=3;
bleme:rp=32,rpt=33,em=10;
bleme:rp=384,rpt=385,em=8;
bleme:rp=384,rpt=385,em=10;
或:如下
RESULT: out.txt
bleme:rp=12,rpt=13,em=0;
bleme:rp=12,rpt=13,em=1;
bleme:rp=12,rpt=13,em=2;
!bleme:rp=13,rpt=12,em=0;
!bleme:rp=13,rpt=12,em=1;
!bleme:rp=13,rpt=12,em=2;
bleme:rp=32,rpt=33,em=0;
bleme:rp=32,rpt=33,em=1;
bleme:rp=32,rpt=33,em=2;
bleme:rp=32,rpt=33,em=3;
bleme:rp=32,rpt=33,em=10;
!bleme:rp=33,rpt=32,em=0;
!bleme:rp=33,rpt=32,em=1;
!bleme:rp=33,rpt=32,em=2;
!bleme:rp=33,rpt=32,em=3;
!bleme:rp=33,rpt=32,em=10;
bleme:rp=384,rpt=385,em=8;
bleme:rp=384,rpt=385,em=10;
!bleme:rp=385,rpt=384,em=8;
!bleme:rp=385,rpt=384,em=10;
有高手赐教一下啊!!