如何同时删除VB列表框中多个选项

2024-12-02 03:53:31
推荐回答(3个)
回答1:

用ckear方法
如:
List1.clear 这个是清空

或者RemoveItem方法
如:
list1.RemoveItem.序号
哈哈~注意看我是谁~

回答2:

Private Sub Command1_Click()
For i = List1.ListCount - 1 To 1 Step -1
If List1.Selected(i) Then
List1.RemoveItem i
End If
Next i
End Sub

Private Sub Form_Load()
List1.AddItem "abc"
List1.AddItem "def"
List1.AddItem "ghi"

List1.AddItem "123"
List1.AddItem "456"
List1.AddItem "789"

List1.AddItem "~!@"
List1.AddItem "#$%"
List1.AddItem "^&*"
List1.AddItem "()_"

End Sub

回答3:

dim i as integer
if list1.listcount<=0 then exit sub
for i=list1.listcount-1 to 0 step -1
if list1(i).selected then
list1.removeitem i
end if
next