供参考
Public Sub sort(sName As String, limit As String, dName As String, Lst As ListBox)
'sName 原文件名
'dName 存放结果文件名
'limit 原文件分隔符,注意中英文标点
'Lst 列表框,借助其排序功能,要在设计状态设置 sorted = true 如果数据量很大,运行缓慢,就要重新排序方法了
Dim str
As String
Dim age As Long
Dim k As Long
Dim i As Long
i = 0
Open sName For Input As 1#
Do While Not EOF(1)
Line Input #1, str
k = InStr(str, limit)
age = Val(Mid(str, k + 1, Len(str)))
Lst.AddItem age & i & "," & str
i = i + 1
Loop
Close #1
Open dName For Output As 2#
For i = 0 To Lst.ListCount - 1
str = Lst.List(i)
k = InStr(str, ",")
Print #2, Mid(str, k + 1, Len(str))
Next
Close #2
Lst.Clear
End Sub