i want to remove single items from list and want to keep duplicate items in listbox
You mean just remove selected item?
Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
See if this helps.
Public Class Form1
Private arlTemp As New ArrayList
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
With ListBox1
arlTemp.AddRange(.Items) '// store all lb.items.
With .Items
.Clear() '// clear lb.items for new input.
For i As Integer = 0 To arlTemp.Count - 1 '// loop thru ArrayList.
If Not i + 1 = arlTemp.Count Then '// verify that i+1 will Not look for an item that isNot there.
For x As Integer = i + 1 To arlTemp.Count - 1 '// loop thru ArrayList again, starting at the next item.
If arlTemp(i) = arlTemp(x) Then '// locate similar item.
.Add(arlTemp(i)) '// add to lb(ListBox).
Exit For '// since done, exit the loop.
End If
Next
End If
Next
End With
End With
End Sub
End Class
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384