VB listbox中selected问题
PrivateSubcmdDelete_Click()DimiAsIntegerFori=0TolstSelect.ListCount-1IflstSelect.Sele...
Private Sub cmdDelete_Click()
Dim i As Integer
For i = 0 To lstSelect.ListCount - 1
If lstSelect.Selected(i) = True Then
lstSelect.RemoveItem (i)
'Form2.List1.RemoveItem (i)
End If
Next i
End Sub
为什么会出错啊?
说是If lstSelect.Selected(i) = True Then
index有错 展开
Dim i As Integer
For i = 0 To lstSelect.ListCount - 1
If lstSelect.Selected(i) = True Then
lstSelect.RemoveItem (i)
'Form2.List1.RemoveItem (i)
End If
Next i
End Sub
为什么会出错啊?
说是If lstSelect.Selected(i) = True Then
index有错 展开
展开全部
删除一个选项后 index就发生了改变
Private Sub cmdDelete_Click()
Dim i As Integer
For i = lstSelect.ListCount - 1 To 0 Step -1
If lstSelect.Selected(i) = True Then
lstSelect.RemoveItem (i)
'Form2.List1.RemoveItem (i)
End If
Next i
End Sub
Private Sub cmdDelete_Click()
Dim i As Integer
For i = lstSelect.ListCount - 1 To 0 Step -1
If lstSelect.Selected(i) = True Then
lstSelect.RemoveItem (i)
'Form2.List1.RemoveItem (i)
End If
Next i
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询