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!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:

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

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:

``````If (value <> 'A' Or value <> 'B' Or value <> 'C') Then
'Process other values
else
'Do not process A, B, or C
End If
``````
0
Commented:
Ryan_Kempt,
What if value = A?  You would have:
(True Or False Or False) = True,
which is not our desired logic.
0
Commented:
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
...
``````
0
Author 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
Commented:
>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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.