- Home
·
- Miscellaneous
·
- Compare two list boxes and add the difference to a third. Uses conditional loops. Good for comparin
Compare two list boxes and add the difference to a third. Uses conditional loops. Good for comparin
Compare two list boxes and add the difference to a third. Uses conditional loops. Good for comparing values. Could be used to compare file
Rate Compare two list boxes and add the difference to a third. Uses conditional loops. Good for comparin
(1(1 Vote))
'Add a Command button named Command1
'Place this code in a form
Private Sub Command1_Click()
Dim x, y As Integer
Dim result As Boolean
'Set to false UNTIL it finds a match, then it's TRUE
result = False
For x = 0 To List1.ListCount - 1
For y = 0 To List2.ListCount - 1
If List1.List(x) = List2.List(y) Then
result = True
End If
Next y
If result = False Then
List3.AddItem List1.List(x)
End If
result = False
Next x
Compare2 'Now loop through list2
End Sub
Private Sub Form_Load()
' I added these values for testing
List1.AddItem "a"
List1.AddItem "b"
List1.AddItem "d"
List2.AddItem "a"
List2.AddItem "d"
List2.AddItem "f"
List2.AddItem "t"
End Sub
Private Sub Compare2()
Dim x, y As Integer
Dim result As Boolean
For x = 0 To List2.ListCount - 1
For y = 0 To List1.ListCount - 1
If List2.List(x) = List1.List(y) Then
result = True
End If
Next y
If result = False Then
List3.AddItem List2.List(x)
End If
result = False
Next x
End Sub
Compare two list boxes and add the difference to a third. Uses conditional loops. Good for comparin Comments
No comments yet — be the first to post one!
Post a Comment