We help IT Professionals succeed at work.

Populate TreeView from Array using vb script

Steve Sibley
Steve Sibley asked
on
134 Views
Last Modified: 2018-03-22
I have an array that identifies the level in the Tree that I want.  I know that I need to do a recursive routine, but I keep getting stuck.  I have the first node created.  Now I need to recursively explode the subnodes of each of the level 1 nodes.  Here is the data:
Seq      bom_level      Node_text
0      1      1__1100-079__UMBRELLA SUPPORT
1      2      2__1100-079-003__SUPPORT UMBRELLA
2      3      3__1100-079-003-001__TUBE STAND
3      4      4__TR3C-0150.0009__TUBE_RND_CARBON-C_1.50_.095
4      3      3__1100-079-003-002__PLATE BASE
5      3      3__1100-079-003-003__ANGLE SUPPORT
6      4      4__UA1C-0250.0200.0025__ANGLE_CARBON-H_2.50X2.00_.25
7      4      4__UA1C-0250.0200.0025__ANGLE_CARBON-H_2.50X2.00_.25
8      3      3__1100-079-003-004__BAR SUPPORT
9      4      4__BS1C-0050__BAR_SQR_CARBON-H_.50
10      2      2__O-059-215__U-BOLT
11      2      2__O-060-003-A__WASHER HARD
12      2      2__O-061-003__WASHER LOCK
13      2      2__O-005-016__SCREW HEX
14      2      2__O-062-009__NUT HEX
15      2      2__O-060-005-A__WASHER HARD
16      2      2__O-059-216__PIN QUICK RELEASE
17      2      2__B-005-052__UMBRELLA W/BRACKET
18      1      1__1100-133__BRAKE ASSEMBLY
19      2      2__D-001-035__CALIPER BRAKE
20      2      2__1100-056-002__DISC BRAKE
21      2      2__1100-056-003__PLATE BLOCK MOUNTING
22      2      2__1100-056-004__SCREW HEX
23      2      2__O-076-024-1__SCREW SOC
24      2      2__O-063-012-A__NUT LOCK
25      2      2__O-063-012-A__NUT LOCK
26      2      2__O-060-006-A__WASHER HARD
27      2      2__K-002-292__BOLT FLANGE
28      2      2__K-002-292__BOLT FLANGE
29      1      1__1100-338__COOLER OIL ELECTRIC COLD WEATHER
30      2      2__K-006-037__COOLER OIL REMOTE
31      2      2__B-004-078__SWITCH
32      2      2__O-001-009__SCREW HEX
33      2      2__O-060-003-A__WASHER HARD
34      1      1__1100-339__COOLER OIL ELECTRIC WO COLD WEATHER

The array contains 1370 Seq numbers.  There are 120 nodes with a BOM_LEVEL of 1.  I found an algorithm in C, but can't convert it and make it work.  Help?
Comment
Watch Question

CERTIFIED EXPERT

Commented:
is there only 3 columns? I'm confused , does the TEXT include the node too?

0      1      1__1100-079__UMBRELLA SUPPORT

Author

Commented:
Yes.  3 columns:  SEQ (Array Row Number); BOM_LEVEL (Tree Level); and Node Text (The text for the TreeNode)
seq                          Level                                                 Node Text
0                                        1                                        1__1100-079__UMBRELLA SUPPORT
1                                        2                                        2__1100-079-003__SUPPORT UMBRELLA
2                                        3                                        3__1100-079-003-001__TUBE STAND
3                                        4                                        4__TR3C-0150.0009__TUBE_RND_CARBON-C_1.50_.095
4                                        3                                        3__1100-079-003-002__PLATE BASE
5                                        3                                        3__1100-079-003-003__ANGLE SUPPORT
6                                        4                                        4__UA1C-0250.0200.0025__ANGLE_CARBON-H_2.50X2.00_.25
7                                        4                                        4__UA1C-0250.0200.0025__ANGLE_CARBON-H_2.50X2.00_.25
8                                        3                                        3__1100-079-003-004__BAR SUPPORT
9                                        4                                        4__BS1C-0050__BAR_SQR_CARBON-H_.50
10                                      2                                        2__O-059-215__U-BOLT

Output should look like

  1__1100-079__UMBRELLA SUPPORT
           2__1100-079-003__SUPPORT UMBRELLA
                  3__1100-079-003-001__TUBE STAND
                         4__TR3C-0150.0009__TUBE_RND_CARBON-C_1.50_.095
                  3__1100-079-003-002__PLATE BASE
                  3__1100-079-003-003__ANGLE SUPPORT
                         4__UA1C-0250.0200.0025__ANGLE_CARBON-H_2.50X2.00_.25
                         4__UA1C-0250.0200.0025__ANGLE_CARBON-H_2.50X2.00
                  3__1100-079-003-004__BAR SUPPORT
                         4__BS1C-0050__BAR_SQR_CARBON-H_.50
             2__O-059-215__U-BOLT
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
The code works.