Forum Moderators: open

Message Too Old, No Replies

If statements - help with syntax

         

pluto2000xx

12:01 am on Apr 7, 2006 (gmt 0)

10+ Year Member



I can't for the life of me get this to work. All I want to do is submit a form and test for two conditions to be true

Example

if sky=blue AND if day=tuesday then
response.write yadayadayada
else
response.write whatever

I only want it to write if BOTH conditions are true.

Can someone please give me the correct syntax (VB)

I've been Googling (can I use that as a verb) for an hour.

Thanks!
Lee

txbakers

1:02 am on Apr 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you're so close!

IF (sky = "blue" AND day = "Tuesday") THEN
do something
ELSE
do something else
END IF

You don't need the parentheses, but I like to use them for clarity.

You do, however, need an END IF in VB.

Also, if you are comparing to string literals, they should be in quotes.

pluto2000xx

1:52 am on Apr 7, 2006 (gmt 0)

10+ Year Member



Thank you so much!

Would it be too easy to assume that if I wanted it to be an "or" instead, I could just change AND to OR?

Lee

txbakers

4:58 am on Apr 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



way too easy.

it's when you mix ANDS and ORS that my head starts to spin.

carguy84

6:52 am on Apr 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mixing ands and ors is where parenthesis really help too.