Solved

How to check if a Listbox already contains a value?

Posted on 2008-10-07
3
261 Views
Last Modified: 2013-11-26
Hi Guys

Just need a quick hint with fixing a Check for Listbox contains value statement.

The code below does not return my Msgbox as it should.

Dim MyService As New ListView

        MyService.Text = NewServiceTextBox.Text

        If ListBox12.Items.Contains(MyService.Text) = True Then

            MsgBox("Service Exists")

        End If

Open in new window

0
Comment
Question by:SasfinSD
  • 2
3 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22658543
use:
If not ListBox12.Items.FindByValue(MyService.Text) is Nothing) then

Open in new window

0
 

Accepted Solution

by:
SasfinSD earned 0 total points
ID: 22658636
I'm using Vs2008

FindbyValue is not a member of "System.Windows.Forms.ListBox.ObjectCollection

What now?
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22658688
I see...
Dim MyService As New ListView

        MyService.Text = NewServiceTextBox.Text

        If ListBox12.Items.IndexOf(MyService.Text) >= 0 Then

            MsgBox("Service Exists")

        End If

Open in new window

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now