我需要从使用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
Run Code Online (Sandbox Code Playgroud)
Ship
是我创造的"阶级".tempList …