Solved

How to check if a Listbox already contains a value?

Posted on 2008-10-07
3
262 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

911 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

20 Experts available now in Live!

Get 1:1 Help Now