2012-07-16 54 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