like operator with Or Operator Possible ??

  • Thread starter Thread starter Macdonald
  • Start date Start date
M

Macdonald

I'm using the Like operator to test the domain of a couple of email
addresses.

e.g.

The way it works right now is

A = "*@abc.com"
B = *@xyz.com


If strAddress Like A Then
GoTo ByeBye1
End if

If strAddress Like B Then
GoTo ByeBye2
End if

This all works fine and I could leave it like it is.

But is there not some simple way of using the "Or Operator" with the "Like
Operator" e.g. "Like A Or Like B", (which does not work) perhaps there is
some simple operation that my novice knowledge does not know of. Perhaps my
syntax is just bad.

I'm sure there are complex ways of doing this. I'm mean you could cut the
address out and put it into a string and then compare those strings with Or
but this seems more involved for than I wish. I mean in regular expressions
its as simple as. (.*@abc.com |.*@xyz.com)

I'm using windows 2000, Outlook Mail 2000 standard vba editor in Outlook.

Regards
 
Hi,

you could use the Select-Case statement, e.g.:

Select Case True
Case sAdr Like sA, sAdr Like sB
Stop
Case Else
Stop
End Select

The comma in the first Case means OR. The advantage of Select Case is if
the first expresssion is true then the second won´t be executed.
 
Back
Top