Option Explicit
Private Sub Command1_Click()
'Transfer text 1 to list 1
List1.AddItem Text1.Text
Text1.Text = ""
End Sub
Private Sub Command2_Click()
Dim lCounter As Integer
With List1
'Loop thru all items in list 1
For lCounter = 0 To .ListCount - 1
'If that item is highlighted
If .Selected(lCounter) Then
'Go to sub to check if it is already in list2
CheckPass lCounter
End If
Next
End With
End Sub
Private Sub CheckPass(lintItem As Integer)
Dim lCounter2 As Integer
Dim lFound As Boolean
With List2
If .ListCount = 0 Then
'No entries therefore must be no duplicates
.AddItem List1.List(lintItem)
Else
'Check list for duplicates
'NB there is an API call that does this in one go
'but will use loop for ease at this stage
For lCounter2 = 0 To .ListCount - 1
If List1.List(lintItem) = .List(lCounter2) Then
lFound = True
Exit For
End If
Next
If Not lFound Then .AddItem List1.List(lintItem)
End If
End With
End Sub