select list box

i would like to know how to make a button that when pressed it would select all the contents of a list box and press another button to deselect all the contents of the same list box
440Asked:
Who is Participating?
 
a111a111a111Commented:
Option Explicit

Private Sub Command1_Click()
Dim A%
For A = 0 To 3
 List1.Selected(A) = True
 Next A
End Sub

Private Sub Command2_Click()
Dim A%
For A = 0 To 3
 List1.Selected(A) = False
 Next A

End Sub

Private Sub Form_Load()
Dim Entry
        List1.Clear
        Entry = "Hello"
        List1.AddItem Entry ' Add the entry.
        Entry = "Bill"
        List1.AddItem Entry
        Entry = "This Is"
        List1.AddItem Entry
        Entry = "a Test"
        List1.AddItem Entry

End Sub

0
 
a111a111a111Commented:
Hi,
if you need more assistent let me know.

Thank you.

0
 
a111a111a111Commented:
The key is:

List1.Selected(A) = True

and

List1.Selected(A) = False

Shay.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.