vb 查找txt相同的行,并删除。
txt内容:aaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbccccccccccccccccccccccddddddddddddddddddd...
txt内容:
aaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbb
cccccccccccccccccccccc
ddddddddddddddddddd
aaaaaaaaaaaaaaaaaaa
eeeeeeeeeeeeeeeeeee
ffffffffffffffffffffffffffffffffffffff
aaaaaaaaaaaaaaaaaaa
ggggggggggggggggggg
bbbbbbbbbbbbbbbbbbb
cccccccccccccccccccccc
现在我只要把相同的删除就留一行,比如aaaaaaaaaaaaaaaaaaa在里面有三行,只留一行就可以了,VB怎么能做到呢? 展开
aaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbb
cccccccccccccccccccccc
ddddddddddddddddddd
aaaaaaaaaaaaaaaaaaa
eeeeeeeeeeeeeeeeeee
ffffffffffffffffffffffffffffffffffffff
aaaaaaaaaaaaaaaaaaa
ggggggggggggggggggg
bbbbbbbbbbbbbbbbbbb
cccccccccccccccccccccc
现在我只要把相同的删除就留一行,比如aaaaaaaaaaaaaaaaaaa在里面有三行,只留一行就可以了,VB怎么能做到呢? 展开
2个回答
展开全部
'' 先引用Microsoft Scripting Runtime
Dim i As Long
Dim TextLine As String
Dim arr As New Scripting.Dictionary
Open "d:\1.txt" For Input As #1
While Not EOF(1)
Line Input #1, TextLine
If Not arr.Exists(TextLine) Then arr.Add TextLine, TextLine
Wend
Close #1
Open "d:\2.txt" For Output As #2
For i = 0 To arr.Count - 1
Print #2, arr.Items(i)
Next
Close #2
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
a = Split(Text1.Text, vbCrLf)
For i = 0 To UBound(a)
b = a(i)
For j = i + 1 To UBound(a)
If b = a(j) Then a(j) = ""
Next j
If a(i) <> "" Then c = c & a(i) & vbCrLf
Next i
Text1.Text = c
End Sub
a = Split(Text1.Text, vbCrLf)
For i = 0 To UBound(a)
b = a(i)
For j = i + 1 To UBound(a)
If b = a(j) Then a(j) = ""
Next j
If a(i) <> "" Then c = c & a(i) & vbCrLf
Next i
Text1.Text = c
End Sub
追问
谢谢了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询