标题:如何实现两段代码的连接
只看楼主
yuan1983
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2007-4-29
 问题点数:0 回复次数:4 
如何实现两段代码的连接

就是怎么样把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

搜索更多相关主题的帖子: Dim Integer Function 代码 String 
2007-04-29 16:17
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
得分:0 
同一问题,请不要重复发帖。

我的msn: myfend@
2007-04-29 16:21
Joforn
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:1242
专家分:122
注 册:2007-1-2
得分:0 
自已试下,如果哪里出问题再问,这样自己水平提升的快,也节省别人的时间。

VB QQ群:47715789
2007-04-29 16:21
yuan1983
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2007-4-29
得分:0 

就是怎样在sub 函数里面调用function 中查到的数组呀 谢谢了

2007-04-29 16:24
zhongmj
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-4-14
得分:0 
定义全局变量
2007-04-30 07:08



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-135999-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.153289 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved