Given a dictionary with multiple object keys, if I remove one of these keys, then the values associated with the object keys added after the removed one "shift down", with the value of the object key added immediately after the removed key becoming Empty. See:
Public Sub DictionaryTest()
Dim dict As New Dictionary
Dim key1 As New Dictionary 'or any other initialized object
Dim key2 As New Dictionary 'or any other initialized object
Dim key3 As New Dictionary 'or any other initialized object
dict(key1) = 1
dict(key2) = 2
dict(key3) = 3
Debug.Print dict(key3) = 3 'prints True
Debug.Print dict(key3) = 2 'prints False
Debug.Print dict(key2) = 2 'prints True
Debug.Print IsEmpty(dict(key2)) 'prints False
dict.Remove key1
Debug.Print dict(key3) = 3 'prints False!
Debug.Print dict(key3) = 2 'prints True!
Debug.Print dict(key2) = 2 'prints False!
Debug.Print IsEmpty(dict(key2)) 'prints True!
End Sub
I think that this is because of how dictionaries internally map object keys to a string representation based on their index in dict_pObjectKeys. When one object is removed from this collection, the indices of the other objects automatically shift down, changing their string representations and resulting in this bug.
Given a dictionary with multiple object keys, if I remove one of these keys, then the values associated with the object keys added after the removed one "shift down", with the value of the object key added immediately after the removed key becoming
Empty
. See:I think that this is because of how dictionaries internally map object keys to a string representation based on their index in
dict_pObjectKeys
. When one object is removed from this collection, the indices of the other objects automatically shift down, changing their string representations and resulting in this bug.