Limit selections in a listbox in vb6

listbox, multiple-select, vb6

Solution

Here is the answer:

lstBox1.Selected(lstBox1.ListIndex) = False

Example:

Private Sub lstBox1_Click()
     If lstBox1.SelCount > 8 Then
        MsgBox "Maximum 8 items can be selected."             
       'I want here return false
        lstBox1.Selected(lstBox1.ListIndex) = False
     End if
End Sub

Problem

How can I limit the selection of ListBox in VB6? What I want: User can select maximum 8 Item from ListBox. I am using this code: ``` Private Sub lstBox1_Click() If lstBox1.SelCount > 8 Then MsgBox "Maximum 8 items can be selected." 'I want here return false End if End Sub ```

Original source