我需要从使用VBA创建的函数“返回”对象数组。当我尝试设置的功能它给了我一个错误信息的阵列,说从函数返回对象数组 - 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
返回。
该功能起作用,它只是我无法工作的返回部分。
感谢您的帮助。如果需要更多信息,请告诉我!
你尝试删除功能输出的类型规范的结果呢? – AntiDrondert