Link to home
Start Free TrialLog in
Avatar of Jacque Scott
Jacque ScottFlag for United States of America

asked on

IF...Statement with (n) number of OR's

I need to create an If...Else...Statement where there is going to be multiple 'OR's and I need help on the best way to do this.

Here is my If...Statement where I only have one 'OR'.

If sSFPRNumber = "7185" Or sSFPRNumber = "7481" Then
            nOutsideProvider = 0
 Else
            nOutsideProvider = 1
 End If

I now have all of the numbers in an array and I would like to loop through the array to create the above IF...Statement.
What is the best way to accomplish this?
Avatar of Raynard7
Raynard7

if you have the numbers in an "array" then you can not dynamically create programming constructs (ie if statements)

you could try creating a dictionary object and then checking if the value exists in the list.

If you reference microsoft scripting runtime and do

Dim x as new dictionary

x.add 7185, 0 'the second number is the value returned if this number is the check
x.add 7481, 0

if x.exists(sSFPRNumber) then
     nOutsideProvider = x(sSFPRNumber)
else
    nOutsideProvider = 1
end if
Avatar of Jacque Scott

ASKER

do I need to say    nOutsideProvider = x(sSFPRNumber)

couldn't I just use    nOutsideProvider = 0
ASKER CERTIFIED SOLUTION
Avatar of Raynard7
Raynard7

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I was going to use the For...Each but this is nested in another For.. loop and I was trying to get away from looping so many times.

I am going to give this a try.  Thanks.  
Can you have a multi-dimensional dictionary object?