怎么删除文本中重复段落 用vb

2010-8-2519:21:13xxxxxxxxxxxxxx2010-8-2519:22:52yyyyyyyyyyyyyy2010-8-2519:23:47xxxxxx... 2010-8-25 19:21:13
xxxxxxxxxxxxxx

2010-8-25 19:22:52
yyyyyyyyyyyyyy

2010-8-25 19:23:47
xxxxxxxxxxxxxx

2010-8-25 19:24:47
xxxxxxxxxxxxxx

2010-8-25 19:25:02
yyyyyyyyyyyyyy

2010-8-25 19:30:36
zzzzzzzzzzzzz
展开
 我来答
酱爆小鲤鱼
2010-08-31 · TA获得超过661个赞
知道小有建树答主
回答量:337
采纳率:0%
帮助的人:538万
展开全部
'以下程序经VB测试成功
Private Sub Command1_Click()
Dim a() As String, str As String, k As Integer
Static n%
'获取文本行数
Open "data.txt" For Input As #1
Do While Not EOF(1)
n = n + 1
Input #1, str
Loop
Close #1

'把每一行的内容存在数组里
ReDim a(n)
Open "data.txt" For Input As #1
Do While Not EOF(1)
i = i + 1
Input #1, a(i)
Loop
Close #1

'把不为空的内容重新存在数组里
For i = 1 To n
If a(i) <> "" Then
k = k + 1
a(k) = a(i)
End If
Next i

'如果内容相同,则该行为空
For i = 1 To k - 1
m = i
For j = i + 1 To k
If a(m) = a(j) Then a(j - 1) = "": a(j) = ""
Next j
Next i

'清空原文本内容
Open "data.txt" For Output As #1
Do While Not EOF(1)
Print #1, ""
Loop
Close #1

'将不为空的内容重新写入文本
For i = 1 To k
Open "data.txt" For Append As #1
If a(i) <> "" Then Print #1, a(i)
Close #1
Next i
End Sub
百度网友aa1a393ac
2010-08-31 · TA获得超过220个赞
知道小有建树答主
回答量:421
采纳率:33%
帮助的人:371万
展开全部
Private Sub Command1_Click()
Dim myTempStr As String, myOutputStr As String, myFile As String
myFile = "C:\123.txt" '文件路径
Open myFile For Input As #1
Do Until EOF(1)
Line Input #1, myTempStr
If InStr(1, myOutputStr, myTempStr) = 0 Then myOutputStr = myOutputStr & myTempStr & vbCrLf
Loop
Close
Open myFile For Output As #1
Print #1, myOutputStr
Close
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式