Listbox Questions

Trogdor

Registered User.
Local time
Tomorrow, 09:02
Joined
Oct 22, 2008
Messages
32
Ok.. I haven't really done much with listboxes before so any help would be appreciated..

I have two listboxes which values are associated to events. These events are triggered using buttons, for capturing data. so For example, someone walks into a room a button is pressed, when they take a seat in the room a button is pressed.. so button are associated to events and the listboxes are to organise who the event belongs too. The problem is that sometimes I need the listboxes to always be unselected unless the listbox is clicked. So anyother time nothing can be selected. I have tried..

Code:
   Dim RescanItem as long

    For RescanItem = 0 To Me.lstRescan.ListCount - 1
        Me.lstRescan.Selected(RescanItem) = False
    Next
but that didnt work for me for some reason.

I also need to check if something is selected in a listbox when i click a button. As some buttons can be pressed without having someone in the listbox.

I am not sure how much sense this is making, it is hard to explain I just know what i need to do but not sure how to do it.

As mentioned earlier any help would be fantastic!

Cheers
 
Tested this and it should work...
Code:
    Dim vItem As Variant
    For Each vItem In Me.YourListbox.ItemsSelected
        Me.YourListbox.Selected(vItem) = False
    Next vItem

Which isnt much different from what you have
 
Awesome thanks for that! :)

I also realised that when I did a me.refresh it was re-selecting items in the list boxes, so I just ran the function after a refresh :)

I am still unsure on the checking to see if an item is selected inside the listbox though, but I am now thinking i might be able to see if me.listbox.ItemSelected = true??

Haven't tested it yet just thinking out loud and looking for ideas :)
 
You could use listindex property to check if an item is selected.
 

Users who are viewing this thread

Back
Top Bottom