Results 1 to 2 of 2

Thread: ****----There has to be a solution----****

  1. #1

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    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.

  2. #2
    Addicted Member overhill's Avatar
    Join Date
    Mar 2000
    KS, United States
    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.

    Private Sub Command1_Click()
        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

Click Here to Expand Forum to Full Width