|
-
Nov 19th, 2000, 04:42 PM
#1
Thread Starter
Lively Member
come one, someone gotta know how to merge two lists into one
how can this be done.......
there is a Master and a Secondary list
how do i combine them both into one list called the Merged list box
but if the Master and Secondary list boxes have two items that are the same then only add one of them not both, resulting in, the merged list would contain all the items from both the list boxes, except only add one of the duplicating items.
-
Nov 19th, 2000, 09:24 PM
#2
Addicted Member
This may not be the most efficient but it should work. It assumes that you have lstMaster, lstSecondary, lstMerged, and a command button to merge them.
Code:
Private Sub Command1_Click()
lstMerged.Clear
Dim x As Integer
For x = 0 To lstMaster.ListCount - 1
'-add all of lstMaster to merged list
lstMerged.AddItem lstMaster.List(x)
Next x
Dim y As Integer
Dim Already As Boolean
For x = 0 To lstSecondary.ListCount - 1
'-Check each entry in lstSecondary vs all of merged list
For y = 0 To lstMerged.ListCount - 1
If lstMerged.List(y) = lstSecondary.List(x) Then
Already = True
End If
Next y
If Already = False Then
lstMerged.AddItem lstSecondary.List(x)
End If
Already = False
Next x
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|