[SIZE=2][COLOR=#008000]'add parent node if it doesn't already exist (if so add quantity as a child)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] parentNode [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] TreeNode [/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2] TreeView1.Nodes[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] parentNode.Text = ds.Tables([/SIZE][SIZE=2][COLOR=#800000]"pub_name"[/COLOR][/SIZE][SIZE=2]).Rows(0)([/SIZE][SIZE=2][COLOR=#800000]"name"[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'add requirement as child of parent node[/COLOR][/SIZE]
[SIZE=2]TreeView1.Nodes(parentNode.Index).Nodes.Add(label & [/SIZE][SIZE=2][COLOR=#800000]" = "[/COLOR][/SIZE][SIZE=2] & pub(1)) _[/SIZE]
[SIZE=2].Tag = column & [/SIZE][SIZE=2][COLOR=#800000]"*"[/COLOR][/SIZE][SIZE=2] & pub(0) & [/SIZE][SIZE=2][COLOR=#800000]"&"[/COLOR][/SIZE][SIZE=2] & pub(1)[/SIZE]
[SIZE=2][COLOR=#008000]'add on to total drops[/COLOR][/SIZE]
[SIZE=2]total_drops = total_drops + pub(1)[/SIZE]
[SIZE=2]added_as_child = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'Check if requirement was added as a child[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] added_as_child = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'was not so now create new parent and add requirement as child[/COLOR][/SIZE]
[SIZE=2]TreeView1.Nodes.Add(ds.Tables([/SIZE][SIZE=2][COLOR=#800000]"pub_name"[/COLOR][/SIZE][SIZE=2]).Row(0)([/SIZE][SIZE=2][COLOR=#800000]"name"[/COLOR][/SIZE][SIZE=2])).Nodes.Add(column, label & [/SIZE][SIZE=2][COLOR=#800000]" = "[/COLOR][/SIZE][SIZE=2] & pub(1)) _[/SIZE]
[SIZE=2].Tag = column & [/SIZE][SIZE=2][COLOR=#800000]"*"[/COLOR][/SIZE][SIZE=2] & pub(0) & [/SIZE][SIZE=2][COLOR=#800000]"&"[/COLOR][/SIZE][SIZE=2] & pub(1)[/SIZE]
[SIZE=2][COLOR=#008000]'add on to total drops[/COLOR][/SIZE]
[SIZE=2]total_drops = total_drops + pub(1)[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'clear ds row[/COLOR][/SIZE]
[SIZE=2]ds.Tables([/SIZE][SIZE=2][COLOR=#800000]"pub_name"[/COLOR][/SIZE][SIZE=2]).Rows.Clear()[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]