How to modify it's value while Enumerating?

  • Thread starter Thread starter Shelby
  • Start date Start date
S

Shelby

Hi,
I would like to modify the object's value while enumerating but I get this
error
Additional information: Collection was modified; enumeration operation may
not execute.

This is my code:

Dim icom as MyOwnStructureObj
Dim MyEnum As IDictionaryEnumerator = Myhash.GetEnumerator()
While MyEnum.MoveNext()
icom = MyEnum.Value
icom.myOwnProperty1 = "change value"

Myhash.Item(MyEnum.Key) = icom ' Error occurs here
End While

Thanks
 
Back
Top