请帮忙解答一下这道VB题,谢谢
按图所示,在窗体上添加如下控件:列表框List1、List2,命令按钮Command1~Command4,并设置好相应的属性。窗体加载时,如图3.2所示,在List1中添...
按图所示,在窗体上添加如下控件:列表框List1、List2,命令按钮Command1~Command4,并设置好相应的属性。
窗体加载时,如图3.2所示,在List1中添加“北京”、“上海”、“天津”,List2中添加“广州”、“深圳”、“杭州”。
单击按钮“>”时,将List1中所选中的列表项移动到List2中,单击按钮“<”时,将List2中所选中的列表项移动到List1中。而单击按钮“>>”时,将List1中所有列表项移动到List2中,单击按钮“<<”时,将List2中所有列表项移动到List1中。 展开
窗体加载时,如图3.2所示,在List1中添加“北京”、“上海”、“天津”,List2中添加“广州”、“深圳”、“杭州”。
单击按钮“>”时,将List1中所选中的列表项移动到List2中,单击按钮“<”时,将List2中所选中的列表项移动到List1中。而单击按钮“>>”时,将List1中所有列表项移动到List2中,单击按钮“<<”时,将List2中所有列表项移动到List1中。 展开
2个回答
展开全部
Private Sub Command1_Click()
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) Then
List2.AddItem List1.Text
List1.RemoveItem i
End If
Next i
End Sub
Private Sub Command2_Click()
For i = List2.ListCount - 1 To 0 Step -1
If List2.Selected(i) Then
List1.AddItem List2.Text
List2.RemoveItem i
End If
Next i
End Sub
Private Sub Command3_Click()
For i = List1.ListCount - 1 To 0 Step -1
List2.AddItem List1.List(i)
List1.RemoveItem i
Next i
End Sub
Private Sub Command4_Click()
For i = List2.ListCount - 1 To 0 Step -1
List1.AddItem List2.List(i)
List2.RemoveItem i
Next i
End Sub
Private Sub Form_Load()
With List1
.AddItem "北京"
.AddItem "上海"
.AddItem "天津"
.AddItem "广州"
.AddItem "深圳"
.AddItem "杭州"
End With
End Sub
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) Then
List2.AddItem List1.Text
List1.RemoveItem i
End If
Next i
End Sub
Private Sub Command2_Click()
For i = List2.ListCount - 1 To 0 Step -1
If List2.Selected(i) Then
List1.AddItem List2.Text
List2.RemoveItem i
End If
Next i
End Sub
Private Sub Command3_Click()
For i = List1.ListCount - 1 To 0 Step -1
List2.AddItem List1.List(i)
List1.RemoveItem i
Next i
End Sub
Private Sub Command4_Click()
For i = List2.ListCount - 1 To 0 Step -1
List1.AddItem List2.List(i)
List2.RemoveItem i
Next i
End Sub
Private Sub Form_Load()
With List1
.AddItem "北京"
.AddItem "上海"
.AddItem "天津"
.AddItem "广州"
.AddItem "深圳"
.AddItem "杭州"
End With
End Sub
展开全部
Private Sub Command1_Click()
If List1.ListIndex < 0 Then Exit Sub
List2.AddItem List1.List(List1.ListIndex)
List1.RemoveItem List1.ListIndex
End Sub
Private Sub Command2_Click()
If List2.ListIndex < 0 Then Exit Sub
List1.AddItem List2.List(List2.ListIndex)
List2.RemoveItem List2.ListIndex
End Sub
Private Sub Command3_Click()
For i = 0 To List1.ListCount - 1
List2.AddItem List1.List(i)
Next
List1.Clear
End Sub
Private Sub Command4_Click()
For i = 0 To List2.ListCount - 1
List1.AddItem List2.List(i)
Next
List2.Clear
End Sub
Private Sub Form_Load()
List1.AddItem "北京"
List1.AddItem "上海"
List1.AddItem "天津"
List2.AddItem "广州"
List2.AddItem "深圳"
List2.AddItem "杭州"
List1.Selected(0) = True
Command1.Caption = ">"
Command2.Caption = "<"
Command3.Caption = ">>"
Command4.Caption = "<<"
End Sub
If List1.ListIndex < 0 Then Exit Sub
List2.AddItem List1.List(List1.ListIndex)
List1.RemoveItem List1.ListIndex
End Sub
Private Sub Command2_Click()
If List2.ListIndex < 0 Then Exit Sub
List1.AddItem List2.List(List2.ListIndex)
List2.RemoveItem List2.ListIndex
End Sub
Private Sub Command3_Click()
For i = 0 To List1.ListCount - 1
List2.AddItem List1.List(i)
Next
List1.Clear
End Sub
Private Sub Command4_Click()
For i = 0 To List2.ListCount - 1
List1.AddItem List2.List(i)
Next
List2.Clear
End Sub
Private Sub Form_Load()
List1.AddItem "北京"
List1.AddItem "上海"
List1.AddItem "天津"
List2.AddItem "广州"
List2.AddItem "深圳"
List2.AddItem "杭州"
List1.Selected(0) = True
Command1.Caption = ">"
Command2.Caption = "<"
Command3.Caption = ">>"
Command4.Caption = "<<"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询