Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27382

How to Check If a Single Item from ListBox1 is in ListBox2?

$
0
0
Hello everyone!


I have added a code below a button that checks if the FIRST item in Listbox2 --> "ListBox2.Items(0).toString" exist in listbox1 items or in listbox1.

I wanted to create something like, if the LISTBOX2(0).ITEMS.TOSTRING does not exist in listbox1, then a MESSAGE BOX pops up with a message and tells that the Item does not exist in listbox1!

I have so far used the method below:
Code:

For each Item in Listbox2.Items
If Listbox1.Items.Contains(item) Then
MsgBox("Item already exists in ListBox1")
Else
MsgBox("Item does not exists in Listbox1")
end if

But the messagebox keeps popping up as for each ITEM that contains in ListBox1, even tho the item does not exists, but the messagebox pops up anywas,,,

Hopefully I could get some help with this... Thanks a lot in advance

Viewing all articles
Browse latest Browse all 27382

Trending Articles