Steven Sandford

Steven Sandford

  • NA
  • 18
  • 5.6k

Check if 2 listboxes have selected items

Oct 7 2014 10:28 PM
 Hi Guys,
Fairly new to VB but enjoying making a small app. One thing I am stuck on is trying to check if 2 listboxes have had an item selected.
If the 2 listboxes have an item selected then enable a button.
I have placed the following code inside the Listbox1 Click Event sub which is public.
 
If listbox1.selectedIndex => 0 And listbox2.selectedIndex => 0 Then
    button1.enabled = True
End If 
 
Now this seems to enable my button only if an item is selected in listbox2 and then you need to click twice within listbox1 before it recognises the selection.
I have pieced this together just from google so if I am doing it wrong I would like to know the correct format or the most sound approach.

Thank you 

Answers (2)