vbadictionary

VBA is throwing an error when changing a value in a dictionary


The dictionary is Set, the key is verified as existing, and yet the value will not change without an error 424. What am I doing wrong?

Sub TestDic()
Dim Dic As Dictionary
Set Dic = New Dictionary

Dic.Add "carpenter bee", "wings"
Dic.Add "monkey", "paws"
Dic.Add "time", CDate("2/14/2024")

Debug.Print "Before Value Change"
Dic("time") = CDate("1/14/2024")
Debug.Print "After Value Change"

End Sub

enter image description here


Solution

  • It turns out that this dictionary is an object from a library that is not coherent with what I am trying to acheive. I had to check the object browser before I realize this dictionary was from Selenium Basic instead of MS Scripting Runtime Library.