Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Problem with Like operator in VBA

Discussion in 'Information Technology' started by bobdydd, Jul 28, 2006.

  1. bobdydd

    bobdydd
    Expand Collapse
    Guest

    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
     
  2. Loading...

    Similar Threads Forum Date
    Sikh News Sikhs Face Problems While Carrying Kirpans In Khyber-Pakhtunkhwa - SikhSiyasat.Net Breaking News Jul 29, 2016
    "Dasam" Granth - A Look At The Core Problems Dasam Granth Oct 21, 2015
    Problems In Life Sikh Sikhi Sikhism Apr 13, 2015
    How can I make decent and useful friends and from where ?? most people have a problem with me Sikh Youth Oct 23, 2013
    The Problem with Taking Too Many Vitamins Health & Nutrition Oct 18, 2013

  3. Brendan Reynolds

    Brendan Reynolds
    Expand Collapse
    Guest

    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" <reallyuseful2004@yahoo.co.uk> wrote in message
    news:1148639643.600539.47170@i40g2000cwc.googlegroups.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
    >
     
  4. Lyle Fairfield

    Lyle Fairfield
    Expand Collapse
    Guest

    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
     
  5. Lyle Fairfield

    Lyle Fairfield
    Expand Collapse
    Guest

    Perhaps, I should have said bitwise. I was confused as I had been
    thinking of George Bush who is Not a Bit Wise.
     
  6. bobdydd

    bobdydd
    Expand Collapse
    Guest

    Thanks guys

    I was getting in a pickle with that

    Bob
     

Share This Page