我需要从使用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
是我需要从函数 sortedList
返回的来自 ship
类的对象数组。
这个函数是有效的,只是返回部分我无法使其工作。
谢谢帮助。如果需要更多信息,请告诉我!