Syntax Question

Discussion in 'ASP General' started by J-P-W, Nov 17, 2007.

  1. J-P-W

    J-P-W Guest

    Hi,

    I want to evaluate 2 things, "Area" and "SubsQuestions"

    I need to know if Area = "Six" or Area = "Seven" AND SubsQuestions =
    "Yes"

    Is it

    ....... If Area = "Six" or Area = "Seven" AND SubsQuestions = "Yes"
    Then

    or

    ....... If Area = "Six" AND SubsQuestions = "Yes" or Area = "Seven" AND
    SubsQuestions = "Yes" Then

    To confirm...... Six and No is to be ignored
    ...... Seven and No is to be ignored
    ...... Seven and Yes will be dealt with
    ...... Six and Yes will be dealt with

    I'm getting confused just typing it!

    Thanks

    Jon
     
    J-P-W, Nov 17, 2007
    #1
    1. Advertising

  2. J-P-W wrote:
    > Hi,
    >
    > I want to evaluate 2 things, "Area" and "SubsQuestions"
    >
    > I need to know if Area = "Six" or Area = "Seven" AND SubsQuestions =
    > "Yes"
    >
    > Is it
    >
    > ...... If Area = "Six" or Area = "Seven" AND SubsQuestions = "Yes"
    > Then
    >
    > or
    >
    > ...... If Area = "Six" AND SubsQuestions = "Yes" or Area = "Seven" AND
    > SubsQuestions = "Yes" Then
    >

    Simple grouping

    If Area = "Six" or (Area = "Seven" AND SubsQuestions ="Yes") then

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Nov 17, 2007
    #2
    1. Advertising

  3. J-P-W

    J-P-W Guest

    On 17 Nov, 14:33, "Bob Barrows [MVP]" <>
    wrote:
    > J-P-W wrote:
    > > Hi,

    >
    > > I want to evaluate 2 things, "Area" and "SubsQuestions"

    >
    > > I need to know if Area = "Six" or Area = "Seven" AND SubsQuestions =
    > > "Yes"

    >
    > > Is it

    >
    > > ...... If Area = "Six" or Area = "Seven" AND SubsQuestions = "Yes"
    > > Then

    >
    > > or

    >
    > > ...... If Area = "Six" AND SubsQuestions = "Yes" or Area = "Seven" AND
    > > SubsQuestions = "Yes" Then

    >
    > Simple grouping
    >
    > If Area = "Six" or (Area = "Seven" AND SubsQuestions ="Yes") then
    >
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"- Hide quoted text -
    >
    > - Show quoted text -


    Thanks.

    So I can have:

    If Area = ("Six" AND SubsQuestions = "Yes") or (Area = "Seven" AND
    SubsQuestions = "Yes") Then
    'Do stuff
    Else
    'Do not
    End If

    Cool :)
     
    J-P-W, Nov 17, 2007
    #3
  4. J-P-W wrote:
    >>
    >> - Show quoted text -

    >
    > Thanks.
    >
    > So I can have:
    >
    > If Area = ("Six" AND SubsQuestions = "Yes") or (Area = "Seven" AND
    > SubsQuestions = "Yes") Then
    > 'Do stuff
    > Else
    > 'Do not
    > End If
    >

    No, that is not possible - the first parenthesis is in the wrong location:
    it needs to be infront of Area:

    If (Area = "Six" AND SubsQuestions = "Yes") or _
    (Area = "Seven" AND SubsQuestions = "Yes") Then

    It's also too verbose. This does exactly the same thing (the commutative
    property applies to boolean operators as well as arithmetic operators):

    If (Area = "Six" or Area = "Seven") AND SubsQuestions = "Yes" Then

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Nov 17, 2007
    #4
  5. J-P-W

    J-P-W Guest

    On 17 Nov, 16:21, "Bob Barrows [MVP]" <>
    wrote:
    > J-P-W wrote:
    >
    > >> - Show quoted text -

    >
    > > Thanks.

    >
    > > So I can have:

    >
    > > If Area = ("Six" AND SubsQuestions = "Yes") or (Area = "Seven" AND
    > > SubsQuestions = "Yes") Then
    > > 'Do stuff
    > > Else
    > > 'Do not
    > > End If

    >
    > No, that is not possible - the first parenthesis is in the wrong location:
    > it needs to be infront of Area:
    >
    > If (Area = "Six" AND SubsQuestions = "Yes") or _
    > (Area = "Seven" AND SubsQuestions = "Yes") Then
    >
    > It's also too verbose. This does exactly the same thing (the commutative
    > property applies to boolean operators as well as arithmetic operators):
    >
    > If (Area = "Six" or Area = "Seven") AND SubsQuestions = "Yes" Then
    >
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"


    Whoops that was a typo, however, your last solution is the neatest -
    thanks Bob

    Jon
     
    J-P-W, Nov 17, 2007
    #5
  6. J-P-W

    Evertjan. Guest

    McKirahan wrote on 17 nov 2007 in
    microsoft.public.inetserver.asp.general:

    > Yes; though your first set of parentheses is wrong.
    > Also, for readability, take a look at this:
    >
    > If (SubsQuestions = "Yes" And Area = "Six") _
    > Or (SubsQuestions = "Yes" And Area = "Seven") Then
    > 'Do stuff
    > Else
    > 'Do not
    > End If
    >


    I prefer for readability:

    SQy = SubsQuestions = "Yes"
    A6 = Area = "Six"
    A7 = Area = "Seven"

    If SQy AND (A6 OR A7) Then
    'Do stuff
    Else
    'Do not
    End If

    or:

    SQy = SubsQuestions = "Yes"
    A6 = Area = "Six"
    A7 = Area = "Seven"
    A6orA7 = A6 OR A7

    If SQy AND A6orA7 Then
    'Do stuff
    Else
    'Do not
    End If


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Nov 17, 2007
    #6
  7. "Evertjan." <> wrote in message
    news:Xns99EBC912567ACeejj99@194.109.133.242...
    > McKirahan wrote on 17 nov 2007 in
    > microsoft.public.inetserver.asp.general:
    >
    >> Yes; though your first set of parentheses is wrong.
    >> Also, for readability, take a look at this:
    >>
    >> If (SubsQuestions = "Yes" And Area = "Six") _
    >> Or (SubsQuestions = "Yes" And Area = "Seven") Then
    >> 'Do stuff
    >> Else
    >> 'Do not
    >> End If
    >>

    >
    > I prefer for readability:
    >
    > SQy = SubsQuestions = "Yes"
    > A6 = Area = "Six"
    > A7 = Area = "Seven"
    >
    > If SQy AND (A6 OR A7) Then
    > 'Do stuff
    > Else
    > 'Do not
    > End If
    >
    > or:
    >
    > SQy = SubsQuestions = "Yes"
    > A6 = Area = "Six"
    > A7 = Area = "Seven"
    > A6orA7 = A6 OR A7
    >
    > If SQy AND A6orA7 Then
    > 'Do stuff
    > Else
    > 'Do not
    > End If
    >


    To use a bit of both your suggestions
    testQ = (SubsQuestions = "Yes")
    test6 = (Area = "Six")
    test7 = (Area = "Seven")

    IF testQ then
    IF test6 OR test7 THEN
    'Do stuff
    END IF
    ELSE
    'Do not
    END IF





    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)
     
    ThatsIT.net.au, Nov 18, 2007
    #7
  8. "McKirahan" <> wrote in message
    news:...
    > "ThatsIT.net.au" <me@thatsit> wrote in message
    > news:...
    >>
    >> "Evertjan." <> wrote in message
    >> news:Xns99EBC912567ACeejj99@194.109.133.242...

    >
    > [snip]
    >
    >> >
    >> > I prefer for readability:
    >> >
    >> > SQy = SubsQuestions = "Yes"
    >> > A6 = Area = "Six"
    >> > A7 = Area = "Seven"
    >> >
    >> > If SQy AND (A6 OR A7) Then
    >> > 'Do stuff
    >> > Else
    >> > 'Do not
    >> > End If

    >
    > [snip]
    >
    >> To use a bit of both your suggestions
    >> testQ = (SubsQuestions = "Yes")
    >> test6 = (Area = "Six")
    >> test7 = (Area = "Seven")
    >>
    >> IF testQ then
    >> IF test6 OR test7 THEN
    >> 'Do stuff
    >> END IF
    >> ELSE
    >> 'Do not
    >> END IF

    >
    > Sorry, that's not equivalent;you don't handle:
    > IF test6 OR test7 THEN's ELSE



    yes it is,

    first subquerys must be true or it fails, only if subquerys is true need we
    test test6 or test7
     
    ThatsIT.net.au, Nov 23, 2007
    #8
  9. "McKirahan" <> wrote in message
    news:...
    > "ThatsIT.net.au" <me@thatsit> wrote in message
    > news:...
    >>
    >> "McKirahan" <> wrote in message
    >> news:...
    >> > "ThatsIT.net.au" <me@thatsit> wrote in message
    >> > news:...
    >> >>
    >> >> "Evertjan." <> wrote in message
    >> >> news:Xns99EBC912567ACeejj99@194.109.133.242...
    >> >
    >> > [snip]
    >> >
    >> >> >
    >> >> > I prefer for readability:
    >> >> >
    >> >> > SQy = SubsQuestions = "Yes"
    >> >> > A6 = Area = "Six"
    >> >> > A7 = Area = "Seven"
    >> >> >
    >> >> > If SQy AND (A6 OR A7) Then
    >> >> > 'Do stuff
    >> >> > Else
    >> >> > 'Do not
    >> >> > End If
    >> >
    >> > [snip]
    >> >
    >> >> To use a bit of both your suggestions
    >> >> testQ = (SubsQuestions = "Yes")
    >> >> test6 = (Area = "Six")
    >> >> test7 = (Area = "Seven")
    >> >>
    >> >> IF testQ then
    >> >> IF test6 OR test7 THEN
    >> >> 'Do stuff
    >> >> END IF
    >> >> ELSE
    >> >> 'Do not
    >> >> END IF
    >> >
    >> > Sorry, that's not equivalent;you don't handle:
    >> > IF test6 OR test7 THEN's ELSE

    >>
    >>
    >> yes it is,
    >>
    >> first subquerys must be true or it fails, only if subquerys is true need

    > we
    >> test test6 or test7

    >
    > Sorry, it's not.
    >
    > If the second test fails you do not perform "Do not".
    >
    > IF testQ then
    > IF test6 OR test7 THEN
    > 'Do stuff
    > ELSE <= you don't allow for this
    > 'Do not
    > END IF
    > ELSE
    > 'Do not
    > END IF
    >


    OK I see what you mean, my error
     
    ThatsIT.net.au, Nov 25, 2007
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gabriele renzi
    Replies:
    2
    Views:
    207
    gabriele renzi
    Dec 31, 2005
  2. Ken Bloom
    Replies:
    3
    Views:
    215
  3. Good Night Moon
    Replies:
    9
    Views:
    284
    Rick DeNatale
    Jul 25, 2007
  4. Jacob Grover
    Replies:
    5
    Views:
    318
    Jacob Grover
    Jul 18, 2008
  5. Mark Richards
    Replies:
    3
    Views:
    316
    Tad McClellan
    Nov 18, 2007
Loading...

Share This Page