Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 if conditional or conditional then not working
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

weeweeslap
Senior Member

USA
1077 Posts

Posted - 18 February 2008 :  20:42:45  Show Profile  Visit weeweeslap's Homepage  Send weeweeslap an AOL message  Send weeweeslap a Yahoo! Message
Hi I have the following conditional:
-code removed-
-edit-
The problem with the code is that for the conditional for work, the user must be both vipallowaccess = 1 and premiumallowaccess = 1. If they only meet one of them, it'll treat them as if they don't meet either conditional and shows them the message. What am I doing wrong? I want it so that if they meet either of those conditional to let them on through.
Thanks

coaster crazy

Edited by - weeweeslap on 18 February 2008 21:53:58

AnonJr
Moderator

United States
5768 Posts

Posted - 18 February 2008 :  21:21:15  Show Profile  Visit AnonJr's Homepage
Off the top of my head, I can't see a problem with the code. Have you checked to make sure that PremiumAllowAccess and VIPAllowAccess are being assigned properly?
Go to Top of Page

weeweeslap
Senior Member

USA
1077 Posts

Posted - 18 February 2008 :  21:28:44  Show Profile  Visit weeweeslap's Homepage  Send weeweeslap an AOL message  Send weeweeslap a Yahoo! Message
yesm they are being assigned properly

coaster crazy
Go to Top of Page

phy1729
Average Member

USA
589 Posts

Posted - 18 February 2008 :  21:47:18  Show Profile
try

If VIPAllowAccess = 0 and PremiumAllowAccess = 0 Then


Edit:Closing my tags

Edited by - phy1729 on 18 February 2008 21:47:52
Go to Top of Page

weeweeslap
Senior Member

USA
1077 Posts

Posted - 18 February 2008 :  21:53:33  Show Profile  Visit weeweeslap's Homepage  Send weeweeslap an AOL message  Send weeweeslap a Yahoo! Message
thank you phy1729, that worked. I tried all scenarious, vip only, premoium only, and being both vip and premium and it worked flawlessly! I don't understand though, and should mean that it has to meet both scenarios but that's not the case. Any special reason and works and not or?
Thanks!

coaster crazy
Go to Top of Page

phy1729
Average Member

USA
589 Posts

Posted - 18 February 2008 :  22:15:07  Show Profile
Truth Tables are nice to explain so
What you want:
VIP	Pre	In
0	0	0
0	1	1
1	0	1
1	1	1


And now the logic gates
AND:				OR:
A	B	Out		A	B	Out
0	0	0		0	0	0
0	1	0		0	1	1
1	0	0		1	0	1
1	1	1		1	1	1


what you want looks like OR so
If VIPAllowAccess = 1 or PremiumAllowAccess = 1 Then

would work but you used the negated version (0 not 1) so
If VIPAllowAccess = 0 and PremiumAllowAccess = 0 Then

personally what I would use is
If VIPAllowAccess||PremiumAllowAccess Then

where || means OR but I count bytes most people don't. You'll get the hang of it when you use it enough or design 4 bit adders using logic gates in your spare time. (What's really a pain is division )

Edited by - phy1729 on 18 February 2008 22:15:51
Go to Top of Page

weeweeslap
Senior Member

USA
1077 Posts

Posted - 18 February 2008 :  22:23:40  Show Profile  Visit weeweeslap's Homepage  Send weeweeslap an AOL message  Send weeweeslap a Yahoo! Message
oh! I understand now. Thanks! I appreciate the detailed explanation!

coaster crazy
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 19 February 2008 :  08:23:35  Show Profile  Visit AnonJr's Homepage
That's what I get for trying to give some late-night help.

Good explanation too.
Go to Top of Page

phy1729
Average Member

USA
589 Posts

Posted - 19 February 2008 :  11:08:07  Show Profile
Except I messed up OR doesn't work you'd need NOR or !(A or B) So that's what I get for trying to give some late-night help.
http://www.howstuffworks.com/boolean.htm is a good explanation if you want to go further.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.47 seconds. Powered By: Snitz Forums 2000 Version 3.4.07