By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,423 Members | 2,551 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,423 IT Pros & Developers. It's quick & easy.

Problem with Like operator in VBA

P: n/a
Hi All

A simple line of code , but it has had me thinking for a couple of
hours.

My brain hurts.......can anyone help

This works OK
If txtEMail Like "*@meredydd*" Then
Do this
End if:

But this doesn't
If txtEMail Like "*@meredydd*" XOR "*@jones*" Then
Do this
End if

Is it possible to do this on the same statement

Regards Bob

May 26 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
If txtEmail Like "*@meredydd*" Xor txtEmail Like "*@jones*" Then

I'm not sure you really need Xor instead of Or in this context, as I don't
think a valid e-mail can't be like '*@meredydd*' and also like '*@jones*',
as that would mean that it contained two '@' symbols. I don't suppose it
will hurt anything, but it is probably redundant.

--
Brendan Reynolds
Access MVP

"bobdydd" <re**************@yahoo.co.uk> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
Hi All

A simple line of code , but it has had me thinking for a couple of
hours.

My brain hurts.......can anyone help

This works OK
If txtEMail Like "*@meredydd*" Then
Do this
End if:

But this doesn't
If txtEMail Like "*@meredydd*" XOR "*@jones*" Then
Do this
End if

Is it possible to do this on the same statement

Regards Bob

May 26 '06 #2

P: n/a
XOR is a bit wise operator and unlikely to be applicable as you are
using it (unless I have been missing something for a long time, which
is always possible); typically it's used in cryption and decryption.

Air code

If InStr(txtEmail, "@meredydd") <> 0 AND InStr(txtEmail, "@jones") <> 0
Then

May 26 '06 #3

P: n/a
Perhaps, I should have said bitwise. I was confused as I had been
thinking of George Bush who is Not a Bit Wise.

May 26 '06 #4

P: n/a
Thanks guys

I was getting in a pickle with that

Bob

May 26 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.