VB左边列表加到右边

来源:百度知道 编辑:UC知道 时间:2024/06/05 22:23:30
Private Sub Command1_Click()
On Error Resume Next
Dim a As Integer
While List1.ListCount > 0
For a = 0 To List1.ListCount - 1
If List1.Selected(a) = True Then
List2.AddItem List1.List(a)
List1.RemoveItem a
Exit For
End If
Next a
Wend
End Sub

如上为何不能运行
O(∩_∩)O谢谢

Private Sub Command1_Click()
On Error Resume Next
Dim a As Integer
n = List1.ListCount
While n > 0
For a = List1.ListCount - 1 To 0 Step -1
If List1.Selected(a) = True Then
List2.AddItem List1.List(a)
List1.RemoveItem a
Exit For
End If
Next a
n = n - 1
Wend

End Sub