请教有关数组分类写入
原文本;A 1971 196
A 1974 195
A 1973 195
A 1971 195
A 1972 196
A 1974 190
A 1971 201
A 1976 198
A 1973 200
.
.
.
A 2000 134
程序代码:
Private Sub Command1_Click()
Dim s As String
Dim flag As Integer
myfile1 = App.Path & "\" & "2.txt"
myfile2 = App.Path & "\" & "4.txt"
Open myfile1 For Input As #1
Open myfile2 For Append As #2
Do While Not EOF(1)
Line Input #1, s
Dim arr
arr = Split(s, " ")
For i = 1971 To 2007
If Val(arr(1)) = i Then
Print #2, arr(0); Spc(4); arr(1); Spc(4); arr(2)
End If
flag = flag + 1
Next
Loop
Close #2
Close #1
End Sub
本人想要的结果是:
A 1971 196
A 1971 195
A 1971 201
A 1972 195
A 1972 196
A 1972 198
A 1973 195
A 1973 190
A 1973 200
.
.
.
A 2000 195
解释: 原文件里面,第二列中的年号是无规律排列的,我想把数组按照第二列中的年号由小到大排列,请问如何修改代码?