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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a table in Access, and I want to figure out how I could in VBsc 2

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
0
0
US
I have a table in Access, and I want to figure out how I could in VBscript recursivly go through the table, steps are checking the HParents and LParents for 0,0 then under the first one, find all children, and for each childeren find under that as well like below should return something like:<br><br><FONT FACE=monospace><br>ID1¦HID¦ID¦Name¦Type ¦Val&nbsp;&nbsp;¦Label&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦HParent¦LParent<br>------------------------------------------------------------<br>7&nbsp;&nbsp;¦1&nbsp;&nbsp;¦Labor&nbsp;&nbsp;¦Check¦Labor¦Labor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦0<br>7&nbsp;&nbsp;¦2&nbsp;&nbsp;¦LFD&nbsp;&nbsp;&nbsp;&nbsp;¦Check¦LFD&nbsp;&nbsp;¦Labor Force Data¦7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦1<br>7&nbsp;&nbsp;¦3&nbsp;&nbsp;¦LFDS&nbsp;&nbsp;&nbsp;¦Check¦LFDS ¦State&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦2<br>7&nbsp;&nbsp;¦4&nbsp;&nbsp;¦LFDN&nbsp;&nbsp;&nbsp;¦Check¦LFDN ¦National&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦2<br>7&nbsp;&nbsp;¦5&nbsp;&nbsp;¦LCD&nbsp;&nbsp;&nbsp;&nbsp;¦Check¦LCD&nbsp;&nbsp;¦Labor Cost Data ¦7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦1<br>7&nbsp;&nbsp;¦6&nbsp;&nbsp;¦LCDW&nbsp;&nbsp;&nbsp;¦Check¦LCDW ¦Wages&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦5<br>7&nbsp;&nbsp;¦7&nbsp;&nbsp;¦LCDE&nbsp;&nbsp;&nbsp;¦Check¦LCDE ¦Employment&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦5<br>7&nbsp;&nbsp;¦8&nbsp;&nbsp;¦LCDWR&nbsp;&nbsp;¦Check¦LCDWR¦Wage Ratios&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¦5<br></font><br><br>into:<br><br><FONT FACE=monospace><br>...<br>&lt;input type=&quot;check&quot; name=&quot;Labor&quot;&gt; Labor &lt;/input&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type=&quot;check&quot; name=&quot;LFD&quot;&gt; Labor Force Data &lt;/Input&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type=&quot;check&quot; name=&quot;LFDS&quot;&gt; State &lt;/input&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type=&quot;check&quot; name=&quot;LFDS&quot;&gt; National &lt;/input&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type=&quot;check&quot; name=&quot;LCD&quot;&gt; Labor Cost Data &lt;/input&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type=&quot;check&quot; name=&quot;LCDW&quot;&gt; Wages &lt;/input&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type=&quot;check&quot; name=&quot;LCDE&quot;&gt; Employment &lt;/input&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type=&quot;check&quot; name=&quot;LCDWR&quot;&gt; Wage Ratios &lt;/input&gt;<br>...<br></font><br><br>of cource the actual output, may be in tables, forms, etc to make it into a treelike (or if its IE only, into like a pulldown) but I need something to rescursivly go through , and spit out from top to bottom, at the most it might use 4 recordsets on a stack at a time I would think (rescursive is calling itself right?)<br><br>any help is appreciated. <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>
 
Ok I'm back, I noticed palblano's response way up there( I didnt ignore it) but in any case.<br><br><font color=blue><br><i>What you could do is create a 'Node' class in your script (yes... object oriented script code) that would be searchable by Node.id the id could be synthesized using HParent.LParent.HID, if I understand your schema correctly. Then as each Node instance is created from a row it's parent could be located in memory and the new Node added to it's children collection. </i><br></font><br><br><br>what I want to know is how would I create the class and how to throw the records into it, right now I have it just doing a getrow.<br><br><font color=blue><FONT FACE=monospace><br>sub showtreeat(byref theObj, HpLoc, LpLoc, ShowP)<br>&nbsp;Dim TreeRow<br>&nbsp;TreeRow = UBound(theObj, 2)<br>&nbsp;if ShowP = true then<br>&nbsp;&nbsp;showparent theObj, HpLoc, LpLoc<br>&nbsp;end if<br>&nbsp;for j = 0 to TreeRow<br>&nbsp;&nbsp;If theObj(HP,j) = HpLoc and theObj(LP,j) = LpLoc then<br>&nbsp;&nbsp;&nbsp;if Spaces = 0 and count &gt; 45 and Change=True then<br>&nbsp;&nbsp;&nbsp;&nbsp;Change = False<br>&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr1 = HTMLStr<br>&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = &quot;&quot;<br>&nbsp;&nbsp;&nbsp;end if <br>&nbsp;&nbsp;&nbsp;if theObj(RType,j) &lt;&gt; &quot;DataGroup&quot; then<br>&nbsp;&nbsp;&nbsp;&nbsp;If Spaces = 0 then<br>&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;&lt;TR&gt;&lt;TD bgcolor=&quot;&quot;#000000&quot;&quot;&gt;&lt;Font color=&quot;&quot;white&quot;&quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;&lt;TR&gt;&lt;TD &quot; & gTableCellColor & &quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;&nbsp;writetabs(Spaces)<br>&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & vbcrlf & &quot;&lt;input type=&quot;&quot;&quot; & TheObj(RType, j) & &quot;&quot;&quot; name=&quot;&quot;&quot; & TheObj(Name, j) & &quot;&quot;&quot; value=&quot;&quot;&quot; & TheObj(Value,j) & &quot;&quot;&quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & TheObj(Label, j) <br>&nbsp;&nbsp;&nbsp;If Spaces = 0 then<br>&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;&lt;/Font&gt;&lt;/TD&gt;&lt;/TR&gt;&quot;&nbsp;&nbsp;& vbcrlf & vbcrlf<br>&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;&lt;/TD&gt;&lt;/TR&gt;&quot; & vbcrlf & vbcrlf<br>&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;&nbsp;Count = Count + 1<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;select case theObj(Label,j)<br>&nbsp;&nbsp;&nbsp;case &quot;ESA&quot;, &quot;RM&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;Set objDB = WebConn()<br>&nbsp;&nbsp;&nbsp;&nbsp;if theObj(Label,j) = &quot;ESA&quot; then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set gRS = objDB.EsDataGroup(1)<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set gRS = objDB.ProgCompGroup(1)<br>&nbsp;&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;&nbsp;&nbsp;if not (gRS is nothing) and not (gRS.EOF) then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gRS.MoveFirst<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Do While Not gRS.EOF<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;&lt;TR&gt;&lt;TD &quot; & gTableCellColor & &quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writetabs(Spaces)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & vbcrlf & &quot;&lt;input type=&quot;&quot;&quot; & TheObj(Value, j) & &quot;&quot;&quot; name=&quot;&quot;&quot; & theObj(HID,j) & &quot;_code&quot;&quot; value=&quot;&quot;&quot; & Trim(gRS(&quot;codetype&quot;)) & &quot;~&quot; & Trim(gRS(&quot;groupcode&quot;)) & &quot;&quot;&quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & gRS(&quot;grouptitle&quot;) & &quot;&lt;/TD&gt;&lt;/TR&gt;&quot; & vbcrlf & vbcrlf<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count = Count + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gRS.MoveNext<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Loop<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gRS.Close <br>&nbsp;&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;&nbsp;&nbsp;WebDisConn(objDB)<br>&nbsp;&nbsp;&nbsp;case &quot;O&quot;, &quot;IOC&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;Set objDB = WebConn()<br>&nbsp;&nbsp;&nbsp;&nbsp;if theObj(Label,j) = &quot;O&quot; then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set gRS = objDB.OescodeGroups<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OccVal = &quot;_code&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set gRS = objDB.Sicdiv()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OccVal = &quot;_ind_grp&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;&nbsp;&nbsp;if not (gRS is nothing) and not (gRS.EOF) then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gRS.MoveFirst<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Do While Not gRS.EOF<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;&lt;TR&gt;&lt;TD &quot; & gTableCellColor & &quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writetabs(Spaces)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & vbcrlf & &quot;&lt;input type=&quot;&quot;&quot; & TheObj(Value, j) & &quot;&quot;&quot; name=&quot;&quot;&quot; & theObj(HID,j) & OccVal & &quot;&quot;&quot; value=&quot;&quot;&quot; & gRS(0) & &quot;&quot;&quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & gRS(1) & vbcrlf & &quot;&lt;/TD&gt;&lt;/TR&gt;&quot; & vbcrlf & vbcrlf<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gRS.MoveNext<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Count = Count + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Loop<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gRS.Close<br>&nbsp;&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;&nbsp;&nbsp;WebDisConn(objDB) <br>&nbsp;&nbsp;&nbsp;end select<br>&nbsp;&nbsp;end if<br>&nbsp;&nbsp;Spaces = Spaces + 1<br>&nbsp;&nbsp;showtreeat theObj, theObj(HID, j), theObj(LID, j), False<br>&nbsp;&nbsp;Spaces = Spaces - 1<br>&nbsp;end if<br>next<br>end sub<br></font></font><br><br>these are the other functions used.<br><font color=red><FONT FACE=monospace><br>sub replacelang(byref LangObj, byref AryObj)<br>&nbsp;for w = LBound(AryObj,2) to UBound(AryObj, 2)<br>&nbsp;&nbsp;for x = LBound(LangObj,2) to UBound(LangObj, 2)<br>&nbsp;&nbsp;&nbsp;if AryObj(Label, w) = Cstr(LangObj(LangID, x)) then<br>&nbsp;&nbsp;&nbsp;&nbsp;AryObj(Label, w) = LangLookup(LangObj(LangTab,x), LangObj(LangRadio,x), LangObj(LangType,x))<br>&nbsp;&nbsp;&nbsp;end if<br>&nbsp;&nbsp;next<br>&nbsp;next<br>end sub<br><br>sub writetabs(number)<br>&nbsp;for k = 0 to number<br>&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;     &quot;<br>&nbsp;next<br>end sub<br><br>sub showparent(byref theObj, HpID, LpID)<br>&nbsp;Dim ParentRow<br>&nbsp;ParentRow = UBound(theObj, 2)<br>&nbsp;for j = 0 to ParentRow<br>&nbsp;&nbsp;If theObj(HID,j) = HpID and theObj(LID,j) = LpID then<br>&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & &quot;&lt;TR&gt;&lt;TD &quot; & gTableCellColor & &quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;writetabs(Spaces)<br>&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & vbcrlf & &quot;&lt;input type=&quot; & TheObj(RType, j) & &quot; name=&quot; & TheObj(Name, j) & &quot; value=&quot; & TheObj(Value,j) & &quot;&gt;&quot;<br>&nbsp;&nbsp;&nbsp;HTMLStr = HTMLStr & TheObj(Label, j) & &quot;&lt;/TD&gt;&lt;/TR&gt;&quot; & vbcrlf & vbcrlf<br>&nbsp;&nbsp;&nbsp;Count = Count + 1<br>&nbsp;&nbsp;&nbsp;exit for <br>&nbsp;&nbsp;end if<br>&nbsp;next<br>end sub<br></font></font><br><br>and the main routine<br><font color=blue><FONT FACE=monospace><br>Conn.Open &quot;Tree&quot;, &quot;sa&quot;, &quot;&quot;<br>RS.Open &quot;SELECT Tree.HID, Tree.ID, Tree.Name, InputType.Type, Tree.Val, Tree.Label, Tree.HParent, Tree.LParent FROM Tree INNER JOIN InputType ON Tree.Type = InputType.ID order by Tree.HID, Tree.ID&quot;,Conn, 0,1<br>If not RS.EOF then<br>&nbsp;&nbsp;RS.MoveFirst<br>&nbsp;&nbsp;AryData = RS.GetRows<br>&nbsp;&nbsp;RS.Close<br>end if<br>RS.Open &quot;Select * from LanguageLabel&quot;,Conn, 0,1<br>If not RS.EOF then<br>&nbsp;&nbsp;RS.MoveFirst<br>&nbsp;&nbsp;LangData = RS.GetRows<br>&nbsp;&nbsp;RS.Close<br>end if<br>Set RS = nothing<br>Conn.Close<br>Set Conn = nothing<br><br>replacelang LangData, AryData<br>&nbsp;<br>'&nbsp;&nbsp;-- Starts the simple tree view --<br><br>showtreeat AryData, 0,0, False<br>Response.write &quot;&lt;form action=&quot;&quot;FormatMulti.asp&quot;&quot; method=&quot;&quot;Post&quot;&quot;&gt;&quot; & vbcrlf<br>Response.Write vbtab & &quot;&lt;Table border=0 align=center Width=&quot;&quot;80%&quot;&quot;&gt;&quot; & vbcrlf<br>Response.Write vbtab & vbtab & &quot;&lt;TR&gt;&lt;TD &quot; & gTopColor & &quot; align=center valign=middle colspan=2&gt; &lt;H1&gt; &quot; & LangLookup(&quot;Multi&quot;, &quot;Report&quot;, &quot;Print&quot;) & &quot; &lt;/H1&gt; &lt;/TD&gt;&lt;/TR&gt;&quot; & vbcrlf<br>Response.Write vbtab & vbtab & &quot;&lt;TR&gt;&quot; & vbcrlf<br>Response.Write vbtab & vbtab & vbtab & &quot;&lt;TD &quot; & gTableCellColor & &quot; width=&quot;&quot;50%&quot;&quot; valign=top&gt;&lt;Table border=0 width=&quot;&quot;100%&quot;&quot;&gt;&quot; & vbcrlf & HTMLStr1 & vbcrlf & &quot;&lt;/Table&gt;&lt;/TD&gt;&quot; & vbcrlf<br>Response.Write vbtab & vbtab & vbtab & &quot;&lt;TD &quot; & gTableCellColor & &quot; width=&quot;&quot;50%&quot;&quot; valign=top&gt;&lt;Table border=0 width=&quot;&quot;100%&quot;&quot;&gt;&quot; & vbcrlf & HTMLStr&nbsp;&nbsp;& vbcrlf & &quot;&lt;/Table&gt;&lt;/TD&gt;&quot; & vbcrlf<br>Response.Write vbtab & vbtab & &quot;&lt;/TR&gt;&quot; & vbcrlf<br>Response.Write vbtab & vbtab & &quot;&lt;TR&gt;&lt;TD &quot; & gBottomColor & &quot; align=center valign=middle colspan=2&gt;&lt;input type=&quot;&quot;Submit&quot;&quot;&gt;&lt;/TD&gt;&lt;/TR&gt;&quot; & vbcrlf<br>Response.Write vbtab & &quot;&lt;/Table&gt;&quot; & vbcrlf<br>Response.Write &quot;&lt;/form&gt;&quot; & vbcrlf<br><br>set AryData = nothing<br>Response.Flush<br>Response.write &quot;&lt;/body&gt;&quot; & vbcrlf & &quot;&lt;/html&gt;&quot;<br></font></font> <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>
 
Karl,<br><br>First, remember I'm not a VB developer, all my stuff is done in javascript which supports inheritance so my class designs don't quite translate to VBScript<br><br>&gt; what I want to know is how would I create the class <br><br>You define a class (in VBScript) using the 'Class' keyword then inside the class block you define properties and methods using the 'Private' and 'Public' keywords. So your Node class might look like this<br><br>&lt;script language=vbscript runat=server&gt;<br>Class Node<br>Private _id<br>.... more member variables to contain the data for HTML output<br>Private _children() 'Dynamic array declaration to contain child 'Node' objects<br><br>Public sub init( rs)<br>'rs is a recordset currently pointed to the row that defines this instance of 'Node'<br>_id = rs(&quot;HID&quot;) & &quot;.&quot; & rs(&quot;LID&quot;) ' build the unique id string<br>... set remaining member variable data from the column values<br>end sub<br><br>Public sub addChild( oNode)<br>'Dynamically grow the _children array and add 'oNode' to it<br>end sub<br><br>Public function toHtml<br>'build a string of html containing this nodes values<br>ostr = &quot;&lt;TD&gt;&quot; & _id & &quot;&lt;/TD&gt;&quot;<br>toHtml = ostr<br><br>end function<br><br>.... other subroutines and functions to perform the necessary tasks for a 'Node'<br><br>End Class<br>&lt;/script<br><br>&gt; and how to throw the records into it, right now I have it just doing a getrow.<br><br>Now in your pages script block you can create new nodes like this<br>&lt;%<br>... set up your query and connection and create rs (ADODB.Recordset)<br>dim oNode<br>set oNode = new Node<br>oNode.init rs<br>Response.Write &quot;&lt;table&gt;&lt;tr&gt;&quot; & oNode.toHtml() & &quot;&lt;/tr&gt;&lt;/table&quot;<br>%&gt;<br><br>In my design I also create a tree object that collected all the root level nodes. You might prefer to just have a single 'Node' object to represent the 'tree'.<br><br>Hope this helps<br>-pete<br><br>
 
you cant do classes in VBscript which is why I am doing it in an ActiveX dll, I'm having a bit problem with the collection, which you can see in the VB5/6 Forum. Also in my collection its a single node, with a node collection in them. (Nodes with possible childeren) <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>
 
Karl,<br><br>&gt; you cant do classes in VBscript<br><br>Yes you can, version 5 of the script engine introduced the Class keyword into VBScript and has been out for almost two years now. It even runs in PWS.<br><br>-pete
 
well for one thats not a class module like in VB, I said that mainly because I asked my lead developer if i was able he said, no, but my question you, is using that class thing, how can I Create a single node thing, that'll work with multiple children, check out my collection post in the VB forum as well I've been trying to use the keynames to add without traversin, but I cant get it to act like a tree(where every node can be accessed from anywhere, rather than seperate collections)<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>
 
&gt; well for one thats not a class module like in VB<br><br>I don't understand that statement. You can put that &lt;script&gt; block into it's own file and then use SSI to use it where ever you want. It's not automatically visible since there is no notion of a project the way there is in VB.<br><br>&gt; I asked my lead developer if i was able he said, no<br><br>Well then he was wrong. Perhaps you should get a new 'lead developer'? hehe<br><br>&gt; using that class thing, how can I Create a single node thing, that'll work with multiple children<br><br>Do you have any OOAD experience? That would certainly be a pre-requisite to using an Object Oriented solution.<br><br>&gt; check out my collection post in the VB forum <br><br>Ok, I will.<br><br>&gt; but I cant get it to act like a tree(where every node can be accessed from anywhere, rather than separate collections)<br><br>Well, if by that statement you mean you want to access any node from any other node even when they are not on the same branch? There are several ways to do that 1) each node could have a 'parentNode' member. That allows searching for Nodes 'up the branch' as well as down. 2) You could have 'Tree' class that contains all the 'root' nodes in a collection and each Node would have a 'Tree' member that is set to 'The tree', then if the Node can't find the node requested by searching down the branch, you pass the request to the Tree which has access to all the Nodes.<br><br>-pete<br><br>
 
in a class Module if I made a collection, when adding a node to a collection, theres 2 paramets, the first is the acutal node object, the second is an optional keyname(there can be no duplicate keynames in a collection) each keyname I said is &quot;~&quot; + The HeadID + &quot;¦&quot; + The Leaf ID<br><br>this garantee's uniqueness since every node has it's head+Leaf address is unique, so this way, if I Want to add a node under ~3¦1 (~ is to follow the keyname rule, which cannot have it starting with a number)<br><br>I could do a <br>set TopNode = TheTree.Node(&quot;~3¦1&quot;)<br>then I could just easily add it under by doing so.<br>TopNode.Add ChildNode, &quot;~&quot; + ChildHeadID + &quot;¦&quot; + ChildLeafID<br><br>but unfortunatly, I cannot do<br>TheTree.Node(&quot;~&quot; + ChildHead + &quot;¦&quot; + ChildLeft) because once that node under a root has been established, I cannot reach past the top node, the key is unique only to the new collection, which is seperate from the rest. and the Depth of the tree can be anywhere from 1 even upto 5 levels. <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>
 
correction, to add is, TopNode.Node.Add, and I belive to have some OO experience, I mean I worked alot with C++, but the transgression sometimes to VB, makings me keep wanting to go to C++ for some of the data handeling, shame I cant actually use pointers in VB, but then again, I Still have references to objects. <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>
 
Karl,<br><br>I must apologize for the confusion. In my previous post my use of the term 'collection' did not refer to a VB type. In my mixed language experience, I use the term collection to describe an 'unknown type' used to store a sequence of items. The type could be a simple array or a vector or a map(also known as dictionary), whatever works best for the given problem.<br><br>In your instance, you might consider using a simple array if the VB Collection type is hindering your design. Each node would provide a .equals() function that takes a string parameter and returns true if it's ID matches the requested parameter. Each Node could also provide a .find() function that returns a 'Node' type if found in it's children array. The find() function would of course recurs into each element of the children array looking for the Node in question by calling their find() member function.<br><br>If you used a MIB style ID each outer level Node could also determine if the ID in question would indeed be in it's branch by comparing the ID to it's own level. This would provide a fairly optimized 'find()' algorithm by starting at the 'root node' or the 'Tree' which ever design you go with.<br><br>This provides maximum flexibility in searching the 'collection' of Nodes.<br><br>Again, my apologies for the terminology confusion.<br>-pete<br>
 
I am just trying to find an easier quicker way to manage the data rather than searching through the array over and over again, and would possible help in the future to manage the user interface. Unfortunatly it doesnt seem like anything I'll seem to slap together within 2 days or so. If only I knew how to make the class object in VBscritp behave more like a LinkList/Binary Tree in C++. that I was at least good at. Its doesnt seem so much to be the concept I dont understand, that I understand a little too much, but how to get the current language to work with that concept. <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>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top