I would like to use an if... then statement as follows
if string1 = string2 or string3 then
I get a type mismatch error though, since, I guess, "or" only works with
numerical values. How can I compare the string to more than one value?
As Stuart and John say, you're misusing the OR operator here. It *looks* like
the English language conjunction, but it isn't! It's a logical operator, just
like the < less-than or the + addition operator; and it has a very strict
definition: it takes two arguments, the expression to its left and the
expression to its right.
<expr1> OR <expr2>
is TRUE if either expr1 is true, or expr2 is true; it is FALSE if neither is
true.
Since a string isn't a logical expression, your statement gets a type mismatch
- you're comparing a logical expression (string1 = string2) with a String. If
you're using numbers, then
1 = 2 OR 3
will compare two logical expressions:
1=2 (which is FALSE)
and
3 (which is TRUE, since any nonzero value is true)
and will give TRUE as a result.
Bottom line: you need to use two logical expressions as the arguments to OR:
string1 = string2 ... an expression which is either true or false
string1 = string3 ... another such
string1 = string2 OR string1 = string3 ... will be true if either of the
above is true.
John W. Vinson [MVP]