Conditional giving me fits!  
Author Message
Ramon





PostPosted: Thu Jun 16 10:27:11 CDT 2005 Top

ASP/Active Server Pages >> Conditional giving me fits!

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

Web Programming306  
 
 
Drew





PostPosted: Thu Jun 16 10:27:11 CDT 2005 Top

ASP/Active Server Pages >> Conditional giving me fits! 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


<


>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





PostPosted: Thu Jun 16 10:28:41 CDT 2005 Top

ASP/Active Server Pages >> Conditional giving me fits! 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




>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





PostPosted: Thu Jun 16 11:08:44 CDT 2005 Top

ASP/Active Server Pages >> Conditional giving me fits! Thanks! I must've had an extreme brain fart today!

Thanks a bunch!
Drew



> 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
>
>


>>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
>>
>
>