Я не могу на всю жизнь, пока я получаю несоответствие типов при сортировке коллекции, в которой уже есть объект.
Может кто-нибудь объяснить, почему произошла ошибка, ниже приведен код, который я использую для сортировки коллекции.
Private Sub SortItems(combinedItems As Collection)
Dim counter As Integer, _
counter2 As Integer, _
temp As Variant, _
tempColleciton As New Collection, _
currentSortItem As SortItem, _
nextSortItem As SortItem, _
sortDirection As SortType
sortDirection = SortOrder
For counter = 1 To combinedItems.Count - 1
For counter2 = counter + 1 To combinedItems.Count
Set currentSortItem = combinedItems(counter)
Set nextSortItem = combinedItems(counter2)
If currentSortItem.Key > nextSortItem.Key Then
combinedItems.Remove counter2
If sortDirection = Ascending Then
combinedItems.Add nextSortItem, nextSortItem, counter 'error occurs here if Ascending
Else
combinedItems.Add nextSortItem, nextSortItem, After:=counter 'error occurs here if Decending
End If
End If
Next counter2
Next counter
End Sub