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.

I am not much sure bur you can try this

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

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

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

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

just write (in lst1_click() event) :-

lst2.listindex=lst1.listindex

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! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.