Originally Posted by
Paul_Hossler
Did you try making it a Module Level variable?
This version keeps a max number of keys = 10
If you want to keep on adding, then use the second approach in my #16
Option Explicit
'module level variable
Dim dict As Object
Sub test()
Dim v As Variant
Dim iMax As Long
If dict Is Nothing Then
Set dict = CreateObject("Scripting.Dictionary")
End If
Call test2(10)
Call test2(12)
Call test2(15)
For Each v In dict.items
If v > iMax Then iMax = v
Next
MsgBox iMax
Set dict = Nothing
End Sub
Private Sub test2(N As Long)
Dim K As Long, D As Long
' K is the Key, D is the Data
For K = 1 To 10
D = N * Rnd
If dict.exists(K) Then
If D > dict(K) Then dict(K) = D
Else
dict.Add K, D
End If
Next
End Sub
Thanks , I can see how it will work but not for my issue. I want the dictionary to be populated by the below sub and also accessed each pass in the same sub. I need it to take the value of y from the callcoordinates sub below
Private Sub CalculateCoordinates(sThread, node As IXMLDOMNode)
Dim parent_node As IXMLDOMNode, x As Integer, y As Integer, y_max_branch As Integer, nList As IXMLDOMNodeList
Dim StepId As String, strXpath As String
Dim inputer, inputer2, inputer3, inputer4 As String
Dim stry As String
Call AddCoordinates(node, x, y)
End Sub