VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A-1 ListBox (style =1) select

by twentyleafclover (2 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (5 Votes)

For Beginners. Copy the contents of ListBox1 to ListBox2 where the contents of ListBox1 is checked off. Remove any duplicates from ListBox2 and remove contents of ListBox2 where the contents of ListBox1 becomes unselected. (uhmmm... hope that made sense)

Rate A-1 ListBox (style =1) select

Private Sub List1_Click()
Dim X As Long
Dim y As Long
Dim j As Long
j = 0
' Add selected items to ListBox2
 For X = 0 To List1.ListCount - 1
 If List1.Selected(X) = True Then
  List2.AddItem List1.List(X)
 End If
 Next
 
 ' Get rid of the now unselected items
 
 Dim i As Long
 For y = 0 To List1.ListCount - 1
 For i = 0 To List1.ListCount - 1
 List2.Text = List2.List(i)
 If List2.List(i) = List1.List(y) And List1.Selected(y) = False Then
  List2.RemoveItem i
 End If
 Next i
 Next
'Get rid of any duplicates in ListBox2
 
Do While j < List2.ListCount
 
 List2.Text = List2.List(j)
 
 If List2.ListIndex <> j Then
  List2.RemoveItem j
 Else
  j = j + 1
 End If
Loop
 
End Sub

Download this snippet    Add to My Saved Code

A-1 ListBox (style =1) select Comments

No comments have been posted about A-1 ListBox (style =1) select. Why not be the first to post a comment about A-1 ListBox (style =1) select.

Post your comment

Subject:
Message:
0/1000 characters