我需要從使用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