Hey
I found today that apparently one cannot change an array element's value if that array is stored in a collection. The only way to change it is to remove the array from the collection and replace it with a different one.
Is this true, or have I lost it?
And the output:Code:Dim c As Collection Dim a(0 To 1) As String Dim b(0 To 1) As String Set c = New Collection a(0) = "foo" a(1) = "123" c.Add a, "key1" Debug.Print "0: " & c("key1")(0) Debug.Print "1: " & c("key1")(1) c("key1")(0) = "bar" c("key1")(1) = "789" Debug.Print "0: " & c("key1")(0) Debug.Print "1: " & c("key1")(1) b(0) = "bar" b(1) = "789" c.Add "", "REPLACE", "key1" c.Remove "key1" c.Add b, "key1", , "REPLACE" c.Remove "REPLACE" Debug.Print "0: " & c("key1")(0) Debug.Print "1: " & c("key1")(1)
Code:0: foo 1: 123 0: foo 1: 123 0: bar 1: 789




Reply With Quote
