【发布时间】:2018-01-25 20:19:52
【问题描述】:
我需要从我使用 VBA 创建的函数中“返回”一个对象数组。当我尝试将函数设置为数组时,它会给我一条错误消息,说
对象是必需的。
我不太习惯 VBA,我无法解决这个问题。函数代码如下:
Function sortedList(listRange As Integer, tempList() As ship) As ship
Dim temp As ship
Set temp = Nothing
For i = listRange - 10 To 1 Step -1
For j = 2 To listRange - 10
If tempList(j - 1).Arrival > tempList(j).Arrival Then
Set temp = tempList(j - 1)
Set tempList(j - 1) = tempList(j)
Set tempList(j) = temp
End If
Next j
Next i
'return tempList - how?
Set sortedList = tempList
End Function
Ship 是我创建的“类”。 tempList 是 ship 类中的对象数组,我需要从函数 sortedList 返回。
函数可以工作,只是返回部分我不能工作。
感谢您的帮助。如果需要更多信息,请告诉我!
【问题讨论】:
-
您是否尝试删除函数输出的类型规范?