in application am using list box

i load items from a text file

i want to remove single items from list and want to keep duplicate items in listbox

any help?

Recommended Answers

All 9 Replies

i want to remove single items from list and want to keep duplicate items in listbox

You mean just remove selected item?

noooooooooooooooooooooooo i want to make inverse of duplicate remover

i want to keep save multi items save in list box and remove single items

The answer is still the same, once you have identified the offending entry


i want to make application same as duplicate remover but it dose not remove duplicates it remove single items and keep duplicate , it identify single item him self , i dnt want to select 15000 items

so i think to make inverse of duplicate remover

hello honeybee2090!

here is simple code to perform same action ,

'use this code at you button click event 
   Dim i As Integer
        Dim x As Integer
        Dim no As Integer
        Dim rec As New ArrayList
        For i = 0 To ListBox1.Items.Count - 1

            no = 0
            A = ListBox1.Items(i).ToString
            For x = 0 To ListBox1.Items.Count - 1
                B = ListBox1.Items(x).ToString
                If A = B Then
                    no = no + 1
                    If no >= 2 Then
                        MsgBox("duplicate record=" & B)
                        Exit For
                    End If
                End If

            If no < 2 Then
            End If
        Dim ab As Integer
        For ab = 0 To rec.Count - 1

hope this will solve your prob :) if yes then mark your thread solved and vote me up :)

Best regards

M.Waqas Aslam

what :o , i tested it and then i post this code here , i just again use above mentioned code and if work fine for me , ok here is a sample program which i code for you , hope this time it works for you :)

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
                    End If
            End With
        End With
    End Sub
End Class

oh yes i was makin a lil mistak now its done thx for helping my problem fixed i finsh that thing with u guys help thanks alot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.