VBScript syntax for testing multiple values for a single variable without using multiple "OR" operators

Posted on 2006-04-12
Medium Priority
Last Modified: 2010-05-18
What is the syntax for the determining whether a variable matches a value in a set.  

For example, if I want to determine whether or not a variable is equal to one of many values
if (SECTIONABV = "ACC") or (SECTIONABV = "AIM") or (SECTIONABV = "YYY") or .... then
    do something
end if

I would prefer to compare against a set of values, something like this

if SECTIONABV in ("ACC","AIM","YYY") then
    do something
end if

Question by:despitia2
1 Comment
LVL 66

Accepted Solution

Jim Horn earned 200 total points
ID: 16440133
   Case "ACC", "AIM", "YYY"
      'Do that stuff
   Case Else
      'Do other stuff
End Select

Featured Post

Technology Partners: 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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

839 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