I have 2 user lists.
How do I get it so when I choose Red from the 1 user list it will be picked up in the second user list.
Printable View
I have 2 user lists.
How do I get it so when I choose Red from the 1 user list it will be picked up in the second user list.
is this the sort of thing you require?
Code:Private Sub Form_Load()
List1.AddItem "Red"
List1.AddItem "Blue"
List1.AddItem "Green"
List1.AddItem "Cyan"
List1.AddItem "Magenta"
List1.AddItem "Yellow"
List2.AddItem "Red"
List2.AddItem "Blue"
List2.AddItem "Green"
List2.AddItem "Cyan"
List2.AddItem "Magenta"
List2.AddItem "Yellow"
End Sub
Private Sub List1_Click()
Dim i As Integer
For i = 0 To List2.ListCount - 1
If List2.List(i) = List1.List(List1.ListIndex) Then
List2.ListIndex = i
Exit For
End If
Next i
End Sub
You can shorten it down a little.
Code:Private Sub List1_Click()
List2.Text = List1.Text
End Sub
I feel a little nervous correcting a guru, but shouldn't it be:
Code:List2.AddItem List1.Text
I thought that he had 2 identical ListBox's (each with the same items) and he wanted the second ListBox to select whatever item that was selected in the first ListBox.
what does list1.text return?
Hmm... I suppose Megatron's suggestion is slightly shorter!
:):):):):)