第1个回答 2011-07-27
你是不是想删除选中的项目,可以参考一下我的代码:
Private Sub Command1_Click()
Dim i As Integer
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) Then
List1.RemoveItem i
End If
Next
End Sub
第2个回答 2022-01-20
If ListBox1.ListCount >= 1 Then
If ListBox1.Selected(ListBox1.ListIndex) Then ListBox1.RemoveItem ListBox1.ListIndex
End If
listbox1 为列表框名称
ListBox1.ListIndex 为列表框所选值的行号
ListBox1.Selected() 判断所选的值是否为真(True)
ListBox1.RemoveItem 删除所选的行
第3个回答 2011-07-27
Private Sub Command1_Click()
If List1.SelCount > 0 Then
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) Then List1.RemoveItem i
Next
End If
End Sub
第4个回答 2011-07-27
Private Sub Command1_Click()
Dim a As Integer
While List1.SelCount > 0
For a = 0 To List1.ListCount - 1
If List1.Selected(a) = True Then
List1.RemoveItem
List1.ListIndex
End If
Next a
Exit ForWend
End Sub