View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default update collection of arrays

RBS,

You can do something close to what you want with the
Scripting Dictionary object...
'-------------
Sub test3()
'Requires project reference to "MicrosoftScriptingRuntime"
'Note that the order of the Key and Item arguments are the reverse
'of those in a Collection.
Dim oDic As Scripting.Dictionary
Dim arr(1 To 10)
Set oDic = New Scripting.Dictionary

arr(1) = 5
oDic.Add "a", arr()
MsgBox oDic("a")(1)

arr(1) = 6
oDic("a") = arr()
MsgBox oDic("a")(1)

Set oDic = Nothing
End Sub
'------------------------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"RB Smissaert"
wrote in message

Is it possible to update the value of an array element if that array is held
by a collection?
It seems not:

Sub test2()
Dim oColl As Collection
Dim arr(1 To 10)
Set oColl = New Collection
arr(1) = 5
oColl.Add arr, "a"
MsgBox oColl(1)(1)

oColl(1)(1) = 6
MsgBox oColl(1)(1)
End Sub

Is there any solution for this?
The whole purpose is to store data with nodes of a treeview control and to
have a robust
linkage between the nodes and the stored data.

RBS