【发布时间】:2013-01-22 08:01:58
【问题描述】:
我有两个列表框,正在尝试将列表 1 中的项目添加到列表 2,然后能够一次从列表 2 中删除多个项目。请注意,列表 1 保持不变(这是应该的)。
我的添加项工作正常:
'Add the selected items to List 2
Dim i As Integer
If lst1.ItemsSelected.Count > 0 Then
i = 0
While i < lst1.ListCount
If lst1.Selected(i) Then
lst2.AddItem (lst1.ItemData(i) & ";" & lst1.Column(1, i) & ";")
lst1.Selected(i) = False
End If
i = i + 1
Wend
End If
但是,当我尝试以类似方式从列表 2 中删除项目时,它只会将第一个选定的项目识别为已选中,并跳过我选择的其他项目。这就是问题。这是我的代码:
'Remove the selected items from List 2
Dim i As Integer
If lst2.ItemsSelected.Count > 0 Then
i = lst2.ListCount - 1
While i >= 0
If lst2.Selected(i) Then
lst2.RemoveItem (i)
lst2.Selected(i) = False
End If
i = i - 1
Wend
End If
我怎样才能让它正常工作?
【问题讨论】:
-
您使用的是哪个 MS Office 应用程序?
-
Access 2010 - 抱歉,我应该在描述中包含这个!
标签: vba ms-access listbox multi-select