排序-并删除相同字数据
添加3个控件分别是 Text1 、Text2 和 Command1
在同目录 新建两个文件 111.txt 和 222.txt
Private Sub Command1_Click()
Dim Arry() As String
Dim i As Long, j As Long
Dim x As String, y As String
i = 1
ReDim Preserve Arry(i) As String
Open App.Path & "\111.txt" For Input As #1
While Not EOF(1)
Line Input #1, Arry(i)
i = i + 1
ReDim Preserve Arry(i) As String
Wend
ReDim Preserve Arry(i - 1) As String
Close #1
For i = 1 To UBound(Arry)
For j = 1 To UBound(Arry)
If j < UBound(Arry) Then
If Val(Arry(j)) > Val(Arry(j + 1)) Then
x = Arry(j)
y = Arry(j + 1)
Arry(j) = y
Arry(j + 1) = x
End If
End If
Next
Next
Open App.Path & "\222.txt" For Output As #1
For i = 1 To UBound(Arry)
Print #1, Arry(i)
Next i
Close #1
取读文件位置 = App.Path & "\222.txt"
H = 0
Open 取读文件位置 For Input As #1 '【打开要取读的文件】
Do While Not EOF(1) '【循环每一行】
Line Input #1, temp '【去读内容赋值】
H = H + 1
AB = temp
If AB <> BA Then Text2 = Text2 & temp & vbCrLf
BA = temp
Loop '【结束循环】
Close #1
End Sub
Private Sub Form_Load()
取读文件位置 = App.Path & "\111.txt"
Open 取读文件位置 For Input As #1 '【打开要取读的文件】
Do While Not EOF(1) '【循环每一行】
Line Input #1, temp '【去读内容赋值】
Text1 = Text1 & temp & vbCrLf
Loop '【结束循环】
Close #1
End Sub
_____________________________________________________________________________ _
中磊UG二次开发教程 梅雷著 qq1821117007
学UG就上UG网 http://www.9sug.com/ |