Hi!

    In making my Install list I developed the tree procedures to make a 
tree, it's leaves and children of children.

    Now I don't have to use 4 arrays, or more than one, but I did for the 
very reason to make tree views with several levels.

    So, below are the dimensions, and the calls to make tree children. The 
data for the children is not fixed but a good test.

        Sincerely
        Bruce

Dim strAllTitle, strUnInstallTitle
Dim programArray()
Dim intAllCount, intUnInstallCount
intAllCount = 0: intUnInstallCount = 0
Dim arrayAllByName(), arrayAllByDate(), arrayUnInstallByName(), 
arrayUnInstallByDate()
Dim maxColumns
maxColumns = 5
strAllTitle = "The Installed Applications Total Is: "
strUnInstallTitle = "The UnInstallable Applications Total Is: "
Dim treeOptionNames
treeOptionNames = Array( "Programs By Name", "Programs By Date", "All 
Programs By Name", "All Programs By Date")
'GetAllPrograms

Sub resetTreeView( dObj, treeId, nodeName, nodeData)
'Reset programs Tree View level based on ID.
 dObj.Control( treeId).Clear
 Dim tvRoot
 Set tvRoot = dObj.Control( treeId).NewItem
 tvRoot.Text = nodeName
 tvRoot.Data = nodeData
 dObj.Control( treeId).TopLevel.Insert tvRoot, tviRoot
' GetAllTreeLeaves "tv_Programs", dObj.Control("tv_windows").Root, dObj, 
dArray
End Sub

'This is original and an array has to be passed in.
' The array is either the program list or the list of choice of listing.
' In other words the first time through is the 4 choices and the call inside 
is the program array associated to it.
' Any sub call is another routine just like this for the program list.
Sub GetAllTreeLeaves( treeName, lastNode, dObj, dArray)
 Dim tChildName, tCount, tMax, tLevel, i, j
 Dim tvNewChild, tvNewChildChildren, tvNewChildChildrensChildren
 tCount = 0
 For Each tChildName In dArray
  tCount = tCount + 1
  ' Now create sub tree level with a name and data.
  GetChildNode treeName, lastNode, tvNewChild, dObj, tChildName, tCount
  tMax = intUnInstallCount
  If tCount > 2 Then tMax = intAllCount
  For i = 0 to tMax-1
   Select Case tCount
    Case 1: tChildName = arrayUnInstallByName( i, 0)
    Case 2: tChildName = arrayUnInstallByDate( i, 0)
    Case 3: tChildName = arrayAllByName( i, 0)
    Case 4: tChildName = arrayAllByDate( i, 0)
   End Select
   tLevel = tCount * 100 + i
   GetChildNode treeName, tvNewChild, tvNewChildChildren, dObj, tChildName, 
tLevel
   For j = 0 to maxColumns-1
    tLevel = tCount * 10000 + i * 100 + j
    Select Case tCount
     Case 1: tChildName = arrayUnInstallByName( i, j)
     Case 2: tChildName = arrayUnInstallByDate( i, j)
     Case 3: tChildName = arrayAllByName( i, j)
     Case 4: tChildName = arrayAllByDate( i, j)
    End Select
    Select Case j
     Case 1: tChildName = "Install Date: " & Mid( tChildName, 5, 2) & "/" & 
Right( tChildName, 2) & "/" & Left( Trim( tChildName), 4)
     Case 2: tChildName = "Version: " & Trim( tChildName)
     Case 3: tChildName = "Size: " & Trim( tChildName)
    End Select
    GetChildNode treeName, tvNewChildChildren, tvNewChildChildrensChildren, 
dObj, tChildName, tLevel
   Next
  Next
 Next
End Sub

Sub GetChildNode( treeName, parentNode, tvINew, dObj, tvText, tvData)
 Set tvINew = dObj.Control( treeName).NewItem()
 tvINew.Text = tvText '& tvData
 tvINew.Data = tvData
 ' Note below last node is parent and created is child.
 parentNode.Children.Insert tvINew, tviLast
End Sub

Sub doSorting()
 QuickSort arrayUnInstallByName, 0, intUnInstallCount-1, 0, 4
 QuickSort arrayUnInstallByDate, 0, intUnInstallCount-1, 1, 4
 QuickSort arrayAllByName, 0, intAllCount-1, 0, 4
 QuickSort arrayAllByDate, 0, intAllCount-1, 1, 4
End Sub

Reply via email to