Solved

VB.Net - Find String in Array

Posted on 2016-10-12
3
68 Views
Last Modified: 2016-10-12
Good Day Experts!

I think what I want to do is possible but I am struggling how to get started and I hope you can point me in the right direction.

I have a Case statement that I would like to use a search of  arrayLists to determine which block of Case statement to run.
I have 3 different ArrayLists pre-populated.  I have a DataReader of Accounts  that I need to loop through and determine which block of code to run.  So if the Account is in ArrayList1 run this code, if Account is in ArrayList2 run this code etc...
The Account won't be in multiple ArrayLists.

Case "Account in ArrayList1 = yes"
     ....................

Case "Account in ArrayList2 = yes"
     ...................

Case "Account in ArrayList3 = yes"
     ...................


I have been searching the net for some time and am having a bit of trouble getting started.  Can you help?

Thanks,
jimbo99999
0
Comment
Question by:Jimbo99999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Dustin Saunders earned 500 total points
ID: 41840200
You can use the .Contains() method to determine if a string is in an array.  Here's an example:

        Dim array1() = New String() {"yes", "no", "yes", "yes"}
        Dim array2() = New String() {"yes", "yes", "yes", "yes"}

        If array1.Contains("no") Then
            Console.WriteLine("array1")
        End If

        If array2.Contains("no") Then
            Console.WriteLine("array2")
        End If

        Console.ReadLine()

Open in new window


In this example, the console will read "array1" only.
0
 

Author Comment

by:Jimbo99999
ID: 41840237
Thank you. I have integrated .Contains and running the code now.
0
 

Author Closing Comment

by:Jimbo99999
ID: 41840286
Exactly what I was looking for. It works great!

Thanks,
jimbo99999
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
T-SQL and CLR parameter strings 9 63
CSS question 16 62
Disable the weekends on datepicker control 6 51
.NET XML to Dictionary - XML has repeating node names 8 28
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…
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 …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

732 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