如何实现下面的数组排序 老显示编译错误
Function ArraySum(arr As Variant) As Variant
Dim intCount As Long
Dim ArrayDemo As String
Dim intMark As Long
Dim atemp() As Integer
Dim colTemp As Collection
Dim strField As Integer
Dim strLine As Integer
Dim Lstr As String
Dim FileNumber
Dim f() As Integer
If ExistFile(NormalizePath(Trim$(colTemp(Key_DBPath))) & "BKPF.TXT") = True Then
intCount = ReturnTxtCount(NormalizePath(Trim$(colTemp(Key_DBPath))) & "BKPF.TXT")
Dim colFields As Collection
GetFields "BKPF", colFields
FileNumber = FreeFile ' 取得未使用的档案代码。
Open NormalizePath(Trim$(colTemp(Key_DBPath))) & "BKPF.TXT" For Input As #FileNumber
Dim bGetField As Boolean
bGetField = False
Do While Not EOF(FileNumber)
intMark = intMark + 1
Line Input #FileNumber, Lstr
If InStr(1, Lstr, "|") > 0 Then
If bGetField = False Then
bGetField = True
Else
'将所有科目均拷入临时表中
atemp = Split(Lstr, "|")
'Code
strField = "K" & DelTabAndCrlf(atemp(colFields("FieldKUNNR")))
strLine = "'" & strField & "'"
strLine = strLine & ","
End If
End If
Loop
Close #FileNumber
End If
ArraySum = f()
End Function
上面这一段是查找数组记录下数组的值
下面一段是进行排序
Sub BubbleSort(list() As Double)
' 冒泡法进行排序
Dim First As Double, Last As Double
Dim I As Integer, j As Integer
Dim Temp As Double
I = f()
j = f()
First = LBound(list)
Last = UBound(list)
For I = First To Last - 1
For j = I + 1 To Last
If list(I) > list(j) Then
Temp = list(j)
list(j) = list(I)
list(I) = Temp
End If
Next j
Next I
End Sub