填空题
VB
题号 #1759407
窗体上有List1、List2两个列表框,程序运行时,在两个列表框中分别选中1个项目,如图a所示,单击名称为Command1的“交换”按钮,则把选中的项目互换,互换后的位置不限,如图b所示。下面的程序可实现这一功能,请填空。
Private Sub Command1_Click()
If List1.Text=”” or List2.Text=”” Then
MsgBox”请选择交换的物品!”
Else
List1.AddItem List2.Text
List2.RemoveItem ( 11 )
( 12 )
List1.RemoveItem List1.ListIndex
End If
End Sub
参考答案
暂无
答案解析
11.List2.ListIndex
List2.ListIndex是列表框2中选中项的内容,它已经被添加到列表框1中,因此要从列表框2中移除。
12.List2.AddItem List1.Text
这个语句是向列表框2中添加列表框1中选中项的内容。
List2.ListIndex是列表框2中选中项的内容,它已经被添加到列表框1中,因此要从列表框2中移除。
12.List2.AddItem List1.Text
这个语句是向列表框2中添加列表框1中选中项的内容。