|
楼主 |
发表于 2014-9-21 15:12
|
显示全部楼层
本帖最后由 jessylake 于 2014-9-21 15:44 编辑
无聊的疯子 发表于 2014-9-21 13:08
方法1,先循环把选择了的移出去,并记录选择的信息条数
然后再循环把已经选择了的删除掉,删除的条数和选 ...
终于倒腾出来了,就用了一次正循环,总的来看,应该没有大错,老师你给看看:
Private Sub CommandButton4_Click()
a = ListBox1.ListCount
b = 0
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i - b) Then
k = TextBox4.Value
ListBox2.AddItem
If a = ListBox1.ListCount Then
ListBox2.List(k, 0) = ListBox1.List(i, 0)
ListBox2.List(k, 1) = ListBox1.List(i, 1)
ListBox1.RemoveItem (i)
Else
ListBox2.List(k, 0) = ListBox1.List(i - b, 0)
ListBox2.List(k, 1) = ListBox1.List(i - b, 1)
ListBox1.RemoveItem (i - b)
End If
b = b + 1
ListBox2.Selected(k) = True
TextBox4.Value = k + 1
End If
Next
end sub
初步测了测,好像可以了,等有时间再研究 |
|