关于VB的listbox控件的使用,救命啊,调不出来啊,

2024-12-18 12:29:53
推荐回答(2个)
回答1:

Private Sub Command1_Click()
Dim a As Integer, i As Integer,
For i = 0 To List2.ListCount - 1
If List2.Selected(i) Then
For j = 0 To List1.ListCount - 1
If List2.List(i) = List1.List(j) Then
MsgBox List2.List(i) & "已经选过了"
Exit For
End If
Next j
If j = List1.ListCount Then List1.AddItem List2.List(i)
a = a + 1
End If
Next i
If a = 0 Then MsgBox "请在右边的文本框中选择项目"
End Sub

回答2:

我是用的是逐条判断法