select all in a listbox

G

Guest

How do I select all items in a listbox when a user clicks on a button? I have
some listboxes that have quite a few entries and I wanted to give my users an
easy way to select all items.

Thanks,
Clint Herman
 
G

Guest

Run this code to select all records in the list

For i = 0 To ListBoxName.ListCount - 1
ListBoxName.Selected(i) = true
Next i

To unselect just change it form true to false
 
D

Douglas J. Steele

You can put code behind a "SELECT ALL" button along the lines of:

Dim intLoop As Integer

For intLoop = 0 To Me.MyListBox.Listcount - 1
Me.MyListBox.Selected(intLoop) = True
Next intLoop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top