got a real silly question i have a set of 6 listboxs in a control array, i want to set them in such a way that when i click one the others are unclicked(unhighlighted). i know i can do this with loads of ifs and end ifs but i am also sure that there is another way with like a line or so of code its just my mind is blank?
I'm not sure what you mean by unclicked(unhighlighted), so I will show an example of Enabled instead - based on what you said you should be able to work it out from there.
Code:
Private Sub lstMyArray_Click(Index As Integer)
Dim ctlTempList As Control
For Each ctlTempList In lstMyArray
If ctlTempList.Index <> Index Then
ctlTempList.Enabled = False
End If
Next ctlTempList
End Sub
Dim ctl As Control
For Each ctl In LstOtput
If Not ctl.Index <> Index Then
ctl.ListIndex = "-1"
End If
Next ctl
basically when you click a listbox the selected line turns blue, if so with numnerous listboxs clicked one after the other they all have a selected line visible in blue. the code you supplied almost works as above but on clicking a listbox it unselects all of them inclueding the one clicked then if you click it once more it selects the list clicked.
the effect i am after is i suppose like a set of radio buttons in a frame when one is selected the others are unselected.
To make it work, simply use the _GotFocus event instead of _Click (edit: as you found out already!)
Note that you aren't setting the ListIndex properly.. it is a Numeric property, so you should not be passing it a String (ie: it should be ctl.ListIndex = -1 )