select all in a listbox

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
Back
Top