Some Code Snippits from Week 7

 

Select all items

For i = 0 To List.ListCount - 1
    List.Selected(i) = True
Next i

 

Unselect all items

For i = 0 To List.ListCount - 1
    List.Selected(i) = False
Next i

 

Remove all items

For i = List.ListCount - 1 To 0 Step -1
    List.RemoveItem i
Next i

        Or

        List.Clear

 

Remove selected items

For i = List.ListCount - 1 To 0 Step -1
    If List.Selected(i) Then
            List.RemoveItem i
    End If
Next i

 

Copy selected items from one to another

        For i = 0 To ListSource.ListCount - 1
            If ListSource.Selected(i) Then
                ListTarget.AddItem ListSource.List(i)
            End If
        Next i

 

"Move" selected items from one to another

        For i = ListSource.ListCount - 1 To 0 Step -1
            If ListSource.Selected(i) Then
                ListTarget.AddItem ListSource.List(i)
                ListSource.RemoveItem i
            End If
         Next i

 

Use "DoubleClick" to copy

   Private Sub ListSource_DblClick()
        ListTarget.AddItem ListSource.List(ListSource.ListIndex)
    End Sub

 

Use "DoubleClick" to move

   Private Sub ListSource_DblClick()
        ListTarget.AddItem ListSource.List(ListSource.ListIndex)
        ListSource.RemoveItem ListSource.ListIndex
    End Sub

 

Return to Week 7