View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default update collection of arrays

I think using the node tag looks the simplest option:

Sub AddNodeTag(oNode As Node)

Dim arr(1 To 2, 1 To 35)

With oNode
arr(1, 1) = .KEY
arr(2, 2) = .KEY
.Tag = arr
End With

End Sub



And then when adding a node for example:

Dim arrTag

Set nodX = _
.TreeView1.Nodes.Add(, tvwFirst, LNK, "New Report", 1)

AddNodeTag nodX

arrTag = nodX.Tag

arrTag(2, 10) = "testing"

nodX.Tag = arrTag


The important bit here is to update the tag array values indirectly as doing
the updates directly like this:

nodX.Tag(2, 10) = "testing"

doesn't work. I remember it crashed Excel when I tried this a while ago, but
it doesn't do that now, but the
array values are not updated.


RBS



"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