Vb.NET see if list of string not contains "/"

Posted on 2012-08-16
Last Modified: 2012-08-16
Hi, I have a list(of String) with some elements in it.

I need to know if that list contains("/") at least 1 element and ALSO  NOT contains("/") at least one element then return lets say True

in other words... lets say my list is:

Hi / Earth

I have both, (not with "/"  and with "/")

so I would return True

if list is:

Hi / Hello
Earth /  Sky
Thank / You / Very Much

then I would return False because there is only elements with "/"

can you help ?
Question by:PhilippeRenaud
    LVL 33

    Assisted Solution

    This is one way.  It's probably not the most efficient or fastest:

              Dim lstList As List(Of String)
              Dim blnSlash As Boolean = False
              Dim blnNoSlash As Boolean = False

              For Each strItem As String In lstList
                If strItem.Contains("/") Then
                  blnSlash = True
                  blnNoSlash = True
                End If

              If blnSlash And blnNoSlash Then
              End If
    LVL 1

    Author Comment

    yea,  ill give points for that, is there a way maybe also for one line with linq maybe ?

    ill just wait for my own knowledge but I accept this.
    LVL 83

    Accepted Solution

    You can use either the Find method or the Contains<predicate> method

    If list.Contains(function(x) x.contains("\")) AND list.Contains(function(x) Not X.contains("\"))
    LVL 1

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    779 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

    14 Experts available now in Live!

    Get 1:1 Help Now