[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

VB.Net - Find String in Array

Posted on 2016-10-12
3
Medium Priority
?
93 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

650 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