vb listbox题创建一个应用程序,界面如图所示,要求:设计窗体含两个列表框List1和List2,其中列表框1代表

1个回答

  • Private Sub Command1_Click()

    If List1.ListIndex > -1 Then

    List2.AddItem List1.List(List1.ListIndex)

    Command3.Enabled = True

    End If

    End Sub

    Private Sub Command2_Click()

    If List2.ListIndex > -1 Then

    List2.RemoveItem List2.ListIndex

    End If

    End Sub

    Private Sub Command3_Click()

    Dim s As String, i As Integer

    Command1.Enabled = False

    Command2.Enabled = False

    For i = 1 To List2.ListCount

    s = s " " List2.List(i - 1)

    Next

    MsgBox "购买了" s

    End Sub

    Private Sub Command4_Click()

    Unload Me

    End Sub

    Private Sub Form_Load()

    List1.AddItem "苹果"

    List1.AddItem "橘子"

    List1.AddItem "香蕉"

    List1.AddItem "梨"

    Command1.Caption = "购买"

    Command2.Caption = "退货"

    Command3.Caption = "统计"

    Command3.Enabled = False

    Command4.Caption = "退出"

    End Su