Solved

How to check if a Listbox already contains a value?

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

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 143

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Change to file doesn't show up 16 73
SSIS Start 2 37
Groupbox Control ? 2 27
How to repeat the data 4 30
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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

685 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