2012-07-16 53 views
2

如何限制选择列表框VB6
我想要的:用户可以从列表框中选择最多8个项目。在vb6列表框中限制选择

我使用这个代码:

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 

回答

4

下面是答案:

lstBox1.Selected(lstBox1.ListIndex) = False 

例子:

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