就是怎么样把Function函数和函数连接起来实现数组的查找和排序
Function是用来查找数组的
Sub是用来实现排序的
谢谢了 程序如下
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
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