guys help me with the code for adding items in the combo box but without duplicates. i have an assignment which is a simple web browser. the combo box will be the address bar. and everytime i input an address, it will be added in combo box and should not repeat just like in the browsers. i hope you could help me. thanks

Re: how add items in combo box but without repetition 80 80
Member Avatar

ComboBox.FindString will return the index of an item that matches.

See if this helps.

If combox1.FindString("The String To Search") < 0 Then
            combox1.Items.Add("The String To Search")
        End If
Re: how add items in combo box but without repetition 80 80

Thanks for your valuable sharing of combobox add items.

Re: how add items in combo box but without repetition 80 80

The following will add "some text" to the combo box only if it doesn't already exist.

Dim text As String = "some text"

If Not ComboBox1.Items.Contains(text) Then
    ComboBox1.Items.Add(text)
End If
Be a part of the DaniWeb community

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