Start New Discussion within our Software Development Community

I need to delete duplicating input..
for example.
in a list box I input
a
a
a
b
b

then I want to delete all 'a'
the listbox must show:

b
b

i hope there is someone who can help me..thanks!!

Public Class Form1

Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
lstshow.Items.Add(txtinput.Text)
txtinput.Text = Nothing
End Sub

Private Sub btndelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndelete.Click
Dim delete As String
Dim found As Boolean = False
Dim position As Integer
Dim num As Integer
num = lstshow.Items.Count - 1
delete = InputBox("Enter Item to be Deleted: ")
For i As Integer = 0 To (lstshow.Items.Count - 1)
If delete = lstshow.Items(i) Then
found = True
position = i
lstshow.Items.RemoveAt(position)

End If
Exit For
Next i

End Sub
End Class

Public Class Form1

Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
lstshow.Items.Add(txtinput.Text)
txtinput.Text = Nothing
End Sub

Private Sub btndelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndelete.Click
Dim delete As String
Dim found As Boolean = False
Dim position As Integer
Dim num As Integer
num = lstshow.Items.Count - 1
delete = InputBox("Enter Item to be Deleted: ")
For i As Integer = 0 To (lstshow.Items.Count - 1)
For j As Integer = i To lstshow.Items.Count - 1
If UCase(delete) = UCase(lstshow.Items(i)) Then
found = True
position = i
If found = True Then
lstshow.Items.RemoveAt(position)
End If
End If
Next
Next

End Sub
End Class


thats the code..

This question has already been answered. Start a new discussion instead.