Conditional giving me fits!

Discussion in 'ASP General' started by Drew, Jun 16, 2005.

  1. Drew

    Drew Guest

    I have the following simple conditional on my page,

    If EmpIDError <> 1 Then
    'Show Input items
    End If

    Now I need to add another conditional to this,

    If PosIDError <> 1 Then
    'Show input items
    End If

    So I made it like this,

    If EmpIDError <> 1 OR PosIDError <> 1 Then

    But the problem is that if PosIDError = 1, then it still shows the input
    items. But if I take the EmpIDError <> 1 out then it works with no
    problems. Why would this be like this?

    Thanks,
    Drew
    Drew, Jun 16, 2005
    #1
    1. Advertising

  2. Drew

    Drew Guest

    I never figured out how to get them both on the same line, so I just did
    this,

    <%If EmpIDError <> 1 Then%>
    <%If PosIDError <> 1 Then%>

    And then added two End Ifs after the code...

    thanks,
    drew


    <
    "Drew" <> wrote in message
    news:%...
    >I have the following simple conditional on my page,
    >
    > If EmpIDError <> 1 Then
    > 'Show Input items
    > End If
    >
    > Now I need to add another conditional to this,
    >
    > If PosIDError <> 1 Then
    > 'Show input items
    > End If
    >
    > So I made it like this,
    >
    > If EmpIDError <> 1 OR PosIDError <> 1 Then
    >
    > But the problem is that if PosIDError = 1, then it still shows the input
    > items. But if I take the EmpIDError <> 1 out then it works with no
    > problems. Why would this be like this?
    >
    > Thanks,
    > Drew
    >
    Drew, Jun 16, 2005
    #2
    1. Advertising

  3. Drew

    Mark Schupp Guest

    OR means that the if block should be executed if either condition is true so
    the only way that the code will not execute will be if both variables = 1.
    If you do not want the code to execute when any one of the variables = 1 you
    need to use AND.

    Also, make sure that the variables contain a numeric value (not a string
    containing a numeric). If you are not sure then include a conversion in the
    if statement.

    If CLng(EmpIDError) <> 1 OR CLng(PosIDError) <> 1 Then

    --
    --Mark Schupp


    "Drew" <> wrote in message
    news:%...
    >I have the following simple conditional on my page,
    >
    > If EmpIDError <> 1 Then
    > 'Show Input items
    > End If
    >
    > Now I need to add another conditional to this,
    >
    > If PosIDError <> 1 Then
    > 'Show input items
    > End If
    >
    > So I made it like this,
    >
    > If EmpIDError <> 1 OR PosIDError <> 1 Then
    >
    > But the problem is that if PosIDError = 1, then it still shows the input
    > items. But if I take the EmpIDError <> 1 out then it works with no
    > problems. Why would this be like this?
    >
    > Thanks,
    > Drew
    >
    Mark Schupp, Jun 16, 2005
    #3
  4. Drew

    Drew Guest

    Thanks! I must've had an extreme brain fart today!

    Thanks a bunch!
    Drew

    "Mark Schupp" <> wrote in message
    news:eO$...
    > OR means that the if block should be executed if either condition is true
    > so the only way that the code will not execute will be if both variables =
    > 1. If you do not want the code to execute when any one of the variables =
    > 1 you need to use AND.
    >
    > Also, make sure that the variables contain a numeric value (not a string
    > containing a numeric). If you are not sure then include a conversion in
    > the if statement.
    >
    > If CLng(EmpIDError) <> 1 OR CLng(PosIDError) <> 1 Then
    >
    > --
    > --Mark Schupp
    >
    >
    > "Drew" <> wrote in message
    > news:%...
    >>I have the following simple conditional on my page,
    >>
    >> If EmpIDError <> 1 Then
    >> 'Show Input items
    >> End If
    >>
    >> Now I need to add another conditional to this,
    >>
    >> If PosIDError <> 1 Then
    >> 'Show input items
    >> End If
    >>
    >> So I made it like this,
    >>
    >> If EmpIDError <> 1 OR PosIDError <> 1 Then
    >>
    >> But the problem is that if PosIDError = 1, then it still shows the input
    >> items. But if I take the EmpIDError <> 1 out then it works with no
    >> problems. Why would this be like this?
    >>
    >> Thanks,
    >> Drew
    >>

    >
    >
    Drew, Jun 16, 2005
    #4
    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. Kerry Shetline
    Replies:
    1
    Views:
    6,188
    Kerry Shetline
    Sep 4, 2003
  2. William Z.
    Replies:
    0
    Views:
    468
    William Z.
    Mar 22, 2006
  3. Replies:
    9
    Views:
    19,604
  4. jbrewer

    PIL FITs image decoder

    jbrewer, Nov 22, 2005, in forum: Python
    Replies:
    8
    Views:
    1,736
    jbrewer
    Nov 23, 2005
  5. sixteenmillion

    The giving that keeps on giving

    sixteenmillion, Nov 19, 2007, in forum: C Programming
    Replies:
    0
    Views:
    413
    sixteenmillion
    Nov 19, 2007
Loading...

Share This Page