K
Keith
Hello,
I have two list boxes, List27 and List29. List 27 is a multiselect.
The following code is associated with List27 and runs whenever an item is
clicked in List27.
I had hoped the following code would do the following.
When an item is clicked in List27, it is added to List 29
If the item is clicked again in List27 it is removed from List 29
What is actually happening is that items are added to List29, sometimes two
at a time, and nothing is removed.
What do you suggest?
Thank you,
Keith
code follows:
Private Sub List27_Click()
Dim ctlSource As Control
Dim a as variant
Dim b as variant
Dim c as variant
Set ctlSource = Me.List27
a = List27.ListCount
b = List27.ListIndex
MsgBox "count of items in List27 = " & a & " Listindex = " & b
c = List29.ListCount
For i = 0 To c
If ctlSource.Column(1) = List29.Column(0) Then
List29.RemoveItem (i)
Else
List29.AddItem Item:=ctlSource.Column(1)
End If
Next i
Set ctlSource = Nothing
End Sub
I have two list boxes, List27 and List29. List 27 is a multiselect.
The following code is associated with List27 and runs whenever an item is
clicked in List27.
I had hoped the following code would do the following.
When an item is clicked in List27, it is added to List 29
If the item is clicked again in List27 it is removed from List 29
What is actually happening is that items are added to List29, sometimes two
at a time, and nothing is removed.
What do you suggest?
Thank you,
Keith
code follows:
Private Sub List27_Click()
Dim ctlSource As Control
Dim a as variant
Dim b as variant
Dim c as variant
Set ctlSource = Me.List27
a = List27.ListCount
b = List27.ListIndex
MsgBox "count of items in List27 = " & a & " Listindex = " & b
c = List29.ListCount
For i = 0 To c
If ctlSource.Column(1) = List29.Column(0) Then
List29.RemoveItem (i)
Else
List29.AddItem Item:=ctlSource.Column(1)
End If
Next i
Set ctlSource = Nothing
End Sub