VB,VBS处理文本文件问题 急!!!!!!

来源:百度知道 编辑:UC知道 时间:2024/09/22 01:00:17
一个文全本文件内容如下:
电脑
文本文件
网络
文本文件
网络
网络
操作系统
常识
文本文件
电脑
网络
常识
常识
网络
操作系统
电脑
常识

如何删除重复数据,处理完的文件成这样:
电脑
网络
文本文件
操作系统
常识

用VB或VBS或C都行,只要达到删除重复就行,谢谢!xtanbmy@163.com
我用数组了,但是怎么个算法我还没想明白,还在思考算法,调试程序。
哪位高手能给个算法,谢谢了!!!

Private Sub Command1_Click()
Dim Text() As String
Dim str As String
Open "z:\abc.txt" For Input As #1
Do While Not EOF(1)
Input #1, temptxt
Text1.Text = Text1.Text & temptxt & vbCrLf
Loop
Close #1
Text = Split(Text1.Text, vbCrLf)
Dim Ire As Integer, Jre As Integer
For Ire = 0 To UBound(Text) - 1
For Jre = Ire + 1 To UBound(Text)
If Text(Ire) = Text(Jre) Then Text(Jre) = ""
Next
Next
Text1.Text = ""
For Ire = 0 To UBound(Text)
If Text(Ire) <> "" Then Text1.Text = Text1.Text + Text(Ire) + vbCrLf
Next
End Sub

假设你的文件 为 "C:\abc.txt"
用下面的vb代码可以处理
Private Sub Command1_Click()
Dim a() As String
Open "c:\abc.txt" For Input As #1 ' 打开文件。

Do
i = i + 1
ReDim Preserve a(i)
Input #1, a(i)