I have list1, treeview, list2
list1 has items
treeview1 has items list2 empty or has items populating over time
Now I want to loop through list1 compare it with list2 and if items do not match then remove the items from treeview1,list1.
The small problem I am having now is list1 ends up keeping 1 unwanted item.
list1 treeview1 and list2 over time has same items populated but list2 sometimes may not contain the same value as list1 this is why I need to loop and match strings. If not found then remove the strings from list1 and treeview1 the same items only.
This code below you can paste it into fresh vb6 project just add
1 treeview1 list1 and list2 and 2 command button
Private Sub Command1_Click()
List1.AddItem "dezzzzz"
TreeView1.Nodes.Add , , , "dezzzzz" & "/" & "General"
List1.AddItem "tammy8123"
TreeView1.Nodes.Add , , , "tammy8123" & "/" & "General"
List1.AddItem "sarah7232"
TreeView1.Nodes.Add , , , "sarah7232" & "/" & "General"
List2.AddItem "tammy8123"
End Sub
Private Sub Command2_Click()
Dim i As Integer, ii As Integer
Dim iii As Integer, demopacket() As String
For ii = List1.ListCount - 1 To 0 Step -1
Dim lstUserspacket() As String
lstUserspacket() = Split(List1.List(ii), "/")
For iii = 1 To TreeView1.Nodes.Count
demopacket() = Split(TreeView1.Nodes(iii).Text, "/")
For i = List2.ListCount - 1 To 0 Step -1
Dim listpacket() As String
listpacket() = Split(List2.List(i), "/")
If listpacket(0) = demopacket(0) Then
Exit For
End If
Next
If i = -1 Then
On Error Resume Next
List1.RemoveItem ii
TreeView1.Nodes.Remove iii
End If
Next
Next
End Sub
Private Sub Form_Load()
Call Command1_Click
End Sub