0

hey i would just like to ask. example i have lstbox named lst1 and another listbox named lst2 when i click on a certain data on the lst1 it would also select the corresponding array of the data in lst2. anyone has an idea? thanks.

5
Contributors
6
Replies
7
Views
9 Years
Discussion Span
Last Post by dc_24l
0

I am not much sure bur you can try this

Private Sub List1_Click()
List2.Selected(List1.ListIndex) = List1.ListIndex
End Sub
0

Hi,
the posted code woks
but misses to react while first item selected(index=0)

neglecting that

the code written for the identical data holding listboxes,
is that satisfies or need code for listboxes with different items..?

Venkatramasamy SN

0

Hi,
if you want ot use the two list boxes with different item try the following code

Private Sub List1_Click()
Dim Srcitem As String
Dim ItemFound As Boolean
Srcitem = List1.Text
ItemFound = False
For i = 0 To List2.ListCount - 1
List2.ListIndex = i
If StrComp(Srcitem, List2.Text, vbTextCompare) = 0 Then
ItemFound = True
Exit Sub
Else
ItemFound = False

End If
Next
If ItemFound = False Then
MsgBox "Selceted Item not found in the Second list", vbInformation, "List Select"
End If

End Sub


With regards
Venkatramasamy SN

0

is it more important to get the data item of list2, or to select the data item in list2 ?

0

hey guys, thanks for the idea and help. because im trying to select a particular item in listbox1 and delete the item in it then when i click on it it will also highlight a particular item in the listbox2 and also delete it. i tried some of the codes and it worked. thanks for the help! :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.