hi guys i have one dout, now i take two list box ,one list box contain some of items , if we seletct the first list box item it will go to second list box ok, again i selete the same item in first list list box ... i want error message from second list box like "the item is alredy selected"

plz give d code to me

>plz give d code to me
"Yes Sir!" :D

See if this helps to check a ListBox if it already contains an item, if not add item.
2 ListBoxes

Public Class Form1
   
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With ListBox1.Items '// add items for testing.
            .Add("item 1") : .Add("item 2") : .Add("item 3") : .Add("item 4") : .Add("item 5")
        End With
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        If Not ListBox2.Items.Contains(ListBox1.SelectedItem) Then '// check if item is Not in ListBox2.
            ListBox2.Items.Add(ListBox1.SelectedItem) '// add item.
        Else '// if item already in ListBox2, notify user.
            MsgBox("This item is already in ListBox2.", MsgBoxStyle.Information)
        End If
    End Sub
End Class
Be a part of the DaniWeb community

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