Solved

Simple IF NOT Statement

Posted on 2004-04-06
7
223 Views
Last Modified: 2006-11-17
I have this IF NOT Statement:-

<% if NOT varRequest ="All New loads" OR  varRequest ="All New NEW Loads" then%>

<DIV title="Manifest has arrived">M = Manifest has Arrived</div>
<DIV title="Booked out">B = Load Booked Out</DIV>
<DIV title="Arrival of Driver">A = Arrival of Driver</DIV>
<%end if%>

I have also added an OR in the statement, for some reason it does not pick up the second part of the OR statement.

Am I using the incorrect syntax?  
I have tried:-

<% if NOT varRequest ="All New loads" OR NOT  varRequest ="All New NEW Loads" then%>

and this does not work either.

please help
0
Comment
Question by:Pigdogmonster
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 20 total points
ID: 10765953
Hi Pigdogmonster,

I assume you want:

<% if NOT (varRequest ="All New loads" OR  varRequest ="All New NEW Loads") then%>

Which will display your stuff if neither condition is true.

Tim Cottee
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 
LVL 1

Expert Comment

by:Rajmahesh
ID: 10765987
hi
if both the conditions are checking for not having that value u can use like

<% if varRequest <> "All New loads" OR varRequest <> "All New NEW Loads" then%>

this ll work
0
 

Author Comment

by:Pigdogmonster
ID: 10766035
thats it! thanks.

Do normal IF statements work without the brackets?  i.e

if varRequest ="All New loads" OR  varRequest ="All New NEW Loads" then

These seem to work wothout the brackets?
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 43

Expert Comment

by:TimCottee
ID: 10766041
Rajmahesh,

No you cannot, that will actually make it happen every time, need an AND if you are negatively testing two exclusive conditions:

<% if varRequest <> "All New loads" AND varRequest <> "All New NEW Loads" then%>

Or

<% if NOT varRequest ="All New loads" AND NOT  varRequest ="All New NEW Loads" then%>

Tim.
0
 
LVL 1

Expert Comment

by:Rajmahesh
ID: 10766163
im sorry timcottee
i dint see that
that should be as u said
that's a mistake
0
 
LVL 7

Expert Comment

by:brgivens
ID: 10767541
Rajmahesh's solution will always return true:

if varRequest <> "All New loads" OR varRequest <> "All New NEW Loads"

varRequest = "All New loads"  ->  if False Or True  ->  True
varRequest = "All New NEW Loads"  ->  if True Or False  ->  True

What you probably want is

if varRequest <> "All New loads" AND varRequest <> "All New NEW Loads"

Pigdogmonster, the brackets <> mean "is not equal to".  the condition can also be stated this way:

if Not varRequest = "All New loads" AND Not varRequest = "All New NEW Loads"

or even:

if Not (varRequest = "All New loads" OR varRequest = "All New NEW Loads")

the reason for the OR in the last version is that using the NOT outside the brackets changes the AND to an OR
0
 
LVL 7

Expert Comment

by:brgivens
ID: 10767564
oops... I don't know why I didn't see the two comments above mine... never mind me :|
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question