Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 12th, 2008, 03:08 PM
Authorized User
Points: 254, Level: 5
Points: 254, Level: 5 Points: 254, Level: 5 Points: 254, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2007
Location: , , .
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default "If or" not working

When I do:

<%If x <> "a" then
response.write "HELLO"
End If%>


Or

<%If x <> "b" then
response.write "HELLO"
End If%>


It runs fine, but if I do:

<%If x <> "a" or x <> "b" then
response.write "HELLO"
End If%>


The script runs, but it runs as if I didn't put "a" or "b" into my form.

Can someone tell me why this is happening?

Thanks!

Reply With Quote
  #2 (permalink)  
Old March 12th, 2008, 03:39 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I think you are misunderstanding the logic of the OR operator.

If x gets populated with 'a'
x <> "a" will evaluate to false and processing continues onto the other side of the OR operator
x <> "b" will evaluate to true which causes your response statement to execute.

If x gets populated with 'b'
x <> "a" evaluates to true so the other side of the OR operator is not evaluated and your response statement is executed.

With the OR statement, only one side of the OR needs to evaluate to true for the entire evauation to be true.††

So if you want x to not equal either a or b use the AND operator:
If x <> "a" and x <> "b" then 'do stuff


hth


================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
Reply With Quote
  #3 (permalink)  
Old March 12th, 2008, 04:15 PM
Authorized User
Points: 254, Level: 5
Points: 254, Level: 5 Points: 254, Level: 5 Points: 254, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2007
Location: , , .
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That's a great explanation and it works!

I was originally going to try "and" but I couldn't see the logic behind it. Now with your explanation, it makes sense.

Thanks!!

Reply With Quote
  #4 (permalink)  
Old March 12th, 2008, 06:03 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

No problem, glad it worked out for you.

-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
window.opener working .... not working alyeng2000 Javascript How-To 5 January 5th, 2007 07:05 AM
Web.Config..Working or Not Working peace95 ASP.NET 1.0 and 1.1 Basics 1 September 18th, 2006 06:53 AM
Local COM working , but not working at Web Serv nagen111 .NET Web Services 3 February 19th, 2005 03:22 AM
Example not working CKucler BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 3 December 8th, 2004 10:26 AM
Get Working Copy... not working Enkiel Classic ASP Basics 0 April 21st, 2004 01:41 PM



All times are GMT -4. The time now is 09:19 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.