If-Then test for multiple values

OK - having a bit of a brain fart here, can't seem to figure this one out
I have a list of codes, some of which I do not want to process and I need to test it via an If-Then block, here is what I have:

If value<>'A' and value <> 'B' and value <> 'C' then
...
Else
...
End if

Now, is this code going to process value and say: "If value <> A, B and C then..." (where value has to equal all 3 and fail all the time) or is it going to process it as "If value <> A or B or C then..." (where value can equal any of the 3 values)?

Or should I write it as:

If value <> 'A' OR value <> 'B' OR value <> 'C' then...

essentiall I want to process on values other than A, B or C.

Thanks!
wppiexpertsAsked:
Who is Participating?
 
Jonez176Connect With a Mentor Commented:

If Not (value = A Or Value = B Or Value = C) Then
'Process
else
'Don't process
End If

Open in new window

0
 
Ryan_KemptConnect With a Mentor Commented:

If (value <> 'A' Or value <> 'B' Or value <> 'C') Then
'Process other values
else
'Do not process A, B, or C
End If

Open in new window

0
 
Jonez176Commented:
Ryan_Kempt,
What if value = A?  You would have:
(True Or False Or False) = True,
which is not our desired logic.
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
Jonez176Commented:
wppiexperts,
Just FYI, there are multiple solutions to this problem.  If you apply De Morgan's law to my first post, you would have an equivalent:
If (value <> A And value <> B And value <> C) Then
...

Open in new window

0
 
wppiexpertsAuthor Commented:
so it looks like if I use the OR condition, I need to group all the tests together. Right now, I don't have parenthesis around any (grouping) of them and that may be why the statement isn't catching the values I'm looking for. I'll give it a shot...thanks!
0
 
PaulHewsCommented:
>essentiall I want to process on values other than A, B or C.

Right.  So you were right with your first hunch:

If value<>'A' and value <> 'B' and value <> 'C' then

This means If expression1 is true and expression2 is true and expression3 is true then process, which is what you want.  You don't need any parenthesis here, because the order of operators puts comparison before logical operators.
0
All Courses

From novice to tech pro — start learning today.