- Home
·
- Miscellaneous
·
- Add only unique items to a listbox (no duplicates added). Fast and short without any loops.
Add only unique items to a listbox (no duplicates added). Fast and short without any loops.
Use this method to avoid adding an item to a ListBox that already exists.
It's a lot faster and shorter than submissions that uses loops etc.
Inputs
StringToAdd = the string to add (if not already exists)
lst = your ListBox
Rate Add only unique items to a listbox (no duplicates added). Fast and short without any loops.
(12(12 Vote))
Private Sub AddUnique(StringToAdd As String, lst As ListBox)
lst.Text = StringToAdd
If lst.ListIndex = -1 Then
'it does not exist, so add it..
lst.AddItem StringToAdd
End If
End Sub
Add only unique items to a listbox (no duplicates added). Fast and short without any loops. Comments
No comments yet — be the first to post one!
Post a Comment