Question

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
Was it helpful?

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top