移动是将列表框1中选中的数字移动到列表框2中。
全部是将列表框1中所有数字移动到列表框2中。
Public Class Form1Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.LoadDim i As Integer, a As IntegerRandomize()For i = 0 To 9a = Int(Rnd() * 90) + 10ListBox1.Items.Add(a)Next iEnd Sub'移动按钮Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.ClickIf ListBox1.SelectedIndex <> -1 ThenListBox2.Items.Add(ListBox1.SelectedItem)ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)ElseMsgBox("请先进行选择!")End IfEnd Sub'全部按钮Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.ClickDim n As Integer, i As Integern = ListBox1.Items.CountListBox2.Items.AddRange(ListBox1.Items)ListBox1.Items.Clear()Button1.Enabled = FalseButton2.Enabled = FalseEnd Sub
End Class