,求详细过程,谢谢!!新建一个工程,左右两边各放置一个列表框ListBox的控件List1和List2,在List1中竖排显示内容“第一题、第二题、第三题、第四题、第五题”这五项。在两个列表框>VB
网友回答
【答案】 '将 list2 中选中的项目移动到 list1 中Private Sub Command2_Click() moveSelItem List2, List1End Sub'将 list1 中选中的项目移动到 list2 中Private Sub Command3_Click() moveSelItem List1, List2End Sub'将 source 中选中的项目移动到 target 中(支持多选功能)。Private Sub moveSelItem(source As ListBox, target As ListBox) Dim i As Integer i = 0 While i < source.ListCount If source.Selected(i) Then target.AddItem source.List(i) source.RemoveItem (i) Else i = i + 1 End If WendEnd Sub'将 list2 中所有的项目移动到 list1 中Private Sub Command4_Click() moveAllItem List2, List1End Sub'将 list1 中所有的项目移动到 list2 中Private Sub Command5_Click() moveAllItem List1, List2End Sub'将 source 中所有的项目移动到 target 中。Private Sub moveAllItem(source As ListBox, target As ListBox) Dim i As Integer i = 0 For i = 0 To source.ListCount - 1 target.AddItem source.List(i) Next source.ClearEnd Sub