Private Sub Command1_Click()
Dim n As Integer
For n = 0 To List1.ListCount - 1
If List1.Selected(n) = True Then
List2.AddItem List1.List(n)
End If
Next n
End Sub
这是LIST1中通过按扭添加进LIST2中,但我想一项只能添加一次不能重复添加,该怎么改
...全文
509打赏收藏
List的简单问题
Private Sub Command1_Click() Dim n As Integer For n = 0 To List1.ListCount - 1 If List1.Selected(n) = True Then List2.AddItem List1.List(n) End If Next n End Sub 这是LIST1中通过按扭添加进LIST2中,但我想一项只能添加一次不能重复添加,该怎么改
Private Sub Form_Load()
For i = 1 To 200
List1.AddItem Int(Rnd * 10)
Next
End Sub
Private Sub Command1_Click()
List2.Clear
Dim n As Integer, j As Integer
For n = 0 To List1.ListCount - 1
If List1.Selected(n) = True Then
For j = 0 To List2.ListCount - 1
If List2.List(j) = List1.List(n) Then GoTo there
Next
List2.AddItem List1.List(n)
End If
there:
Next
End Sub