Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Collection key problem

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
US
I have here a subroutine, that populates a collection:<br><br><FONT FACE=monospace><font color=blue><br>Sub LoadAt(TheObj, HpLoc As Integer, LpLoc As Integer)<br>&nbsp;&nbsp;&nbsp;Dim Crn As Node<br>&nbsp;&nbsp;&nbsp;Dim Cn As Node<br>&nbsp;&nbsp;&nbsp;Dim TreeRow<br>&nbsp;&nbsp;&nbsp;TreeRow = UBound(TheObj, 2)<br>&nbsp;&nbsp;&nbsp;For j = 0 To TreeRow<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If TheObj(HP, j) = HpLoc And TheObj(LP, j) = LpLoc Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set Cn = New Node<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cn.HID = TheObj(HID, j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cn.LID = TheObj(LID, j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cn.Name = TheObj(Name, j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cn.RType = TheObj(RType, j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cn.Val = TheObj(Value, j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cn.Label = TheObj(Label, j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If TheObj(LP, j) = &quot;0&quot; Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TheTree.Node.Add Cn, &quot;~&quot; & Cn.HID & &quot;¦&quot; & Cn.LID<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><font color=red>Set Crn = TheTree.Node(&quot;~&quot; & TheObj(HP, j) & &quot;¦&quot; & TheObj(LP, j))</font></b><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Crn.Node.Add Cn, &quot;~&quot; & Cn.HID & &quot;¦&quot; & TheObj(LID, j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LoadAt TheObj, CInt(TheObj(HID, j)), CInt(TheObj(LID, j))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;Next<br>End Sub<br></font></font><br><br>Where the Red bold is, is where my problem occurs, Now I've notice, that it'll do fine if you have a top level node, then add a child to that node, but the problem occurs when I try to use a keyname assigned to a second level node, are the nodes themselves, and the node class they contain, keep itself discrete from each other?, how can I access the key node, not matter where in the tree it'll be located?<br><br> <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
 
Dear Karl,<br><br>Unless I completely misunderstand what you are trying to build, you do not have the correct design to accomplish your goal.<br><br>Root Node<br>-child 1 of root<br>-- child 1 of child one of root<br>-- child 2 of child one of root<br>-child 2 of root<br>-- child 1 of child 2 of root<br>-- child 2 of child 2 of root<br>-- child 3 of child 2 of root<br>--- child 1 of child 3 of child 2 of root<br>.... etc<br><br>This requires each node to have it's own collection from which it can search for the node in question.<br><br>Hope this helps<br>-pete<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top