vb:列表框应用 具体如下
来源:百度知道 编辑:UC知道 时间:2024/09/27 22:19:56
添加两个列表框和四个按钮,其中列表框的属性作如下设置
List1.MultiSelect = True
List2.MultiSelect = True
List1.style=1
然后添加如下代码:
Private Sub command1_click() '移动选中项目
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) Then
List2.AddItem List1.List(i)
List1.RemoveItem i
End If
Next
End Sub
Private Sub command2_click() '添加所有选项至list2
For i = 0 To List1.ListCount - 1
List2.AddItem List1.List(i)
Next
List1.Clear
End Sub
Private Sub command3_click() '移动选中项目
For i = List2.ListCount - 1 To 0 Step -1
If List2.Selected(i) Then
List1.AddItem List2.List(i)
List2.RemoveItem i
End If
Next
End Sub
Private Sub command4_click() '添加所有选项至list2
For i = 0 To List2.ListCount - 1
List1.AddItem List2.List(i)
Next
List2.Clear
End Sub
Private Sub Form_Load