你可真够懒的了!!! 好在我正好也要写一个这样的东西。Option ExplicitPrivate Sub ListItemMove(nFrom As ListBox, nTo As ListBox)
Dim i As Integer
Dim a As Long
a = nFrom.ListCount
Do While i <> a
If nFrom.Selected(i) Then
nTo.AddItem nFrom.List(i)
nFrom.RemoveItem i
a = a - 1
i = i - 1
End If
nFrom.Refresh
i = i + 1
Loop
End Sub
Private Sub Command1_Click()
ListItemMove List1, List2
End SubPrivate Sub Command2_Click()
ListItemMove List2, List1
End SubPrivate Sub Form_Load() Dim i As Integer
With List1
For i = 0 To 9
.AddItem i
Next i
End WithEnd Sub
Dim i As Integer
Dim a As Long
a = nFrom.ListCount
Do While i <> a
If nFrom.Selected(i) Then
nTo.AddItem nFrom.List(i)
nFrom.RemoveItem i
a = a - 1
i = i - 1
End If
nFrom.Refresh
i = i + 1
Loop
End Sub
Private Sub Command1_Click()
ListItemMove List1, List2
End SubPrivate Sub Command2_Click()
ListItemMove List2, List1
End SubPrivate Sub Form_Load() Dim i As Integer
With List1
For i = 0 To 9
.AddItem i
Next i
End WithEnd Sub
快把代码复制到你机子上去吧。
Sub ItemMove(FormList As ListBox, ToList As ListBox)
Dim index As Long
index = 0
Do
If FormList.Selected(index) = True Then
ToList.AddItem FormList.List(index)
FormList.RemoveItem (index)
Else
index = index + 1
End If
Loop Until index = FormList.ListCount
End Sub
Private Sub Form_Load()
Dim i As Long
Do
List1.AddItem i
i = i + 1
Loop Until i > 10
End SubPrivate Sub Command1_Click()
ItemMove List1, List2
End SubPrivate Sub Command2_Click()
ItemMove List2, List1
End Sub