
If statement question
Hi there,<BR><BR>Is there anyway to check two conditions using the same if statement? ie:<BR><BR>if strSomething <> 9983 OR strSomething <> 9984 then

RE: If statement question

RE: If statement question
Yeah, I just did. It works fine with just the first condition, but once I add the OR.... it doesn't work at all. Any thoughts?

Pretend you are a computer.
Evaluate the statement yourself:<BR><BR> if strSomething <> 9983 OR strSomething <> 9984 then<BR><BR>[first of all, I have to ask whey you would be comparing a *STRING* named strSomething to an integer number! but we'll let that go]<BR><BR>Let's suppose that<BR> strSomething = 1111<BR><BR>SO:<BR> if strSomething <> 9983 OR strSomething <> 9984 then<BR><BR>Okay...So *IS* strSomething <> 9983? You betcha. That's true.<BR>And *IS* strSomething <> 9984? Yep! Also true.<BR><BR>So we just converted<BR> if strSomething <> 9983 OR strSomething <> 9984 then<BR>to<BR> if (strSomething <> 9983) OR (strSomething <> 9984) then<BR>and then to<BR> if (True) OR (True) then<BR>and of course if both are true then the OR doesn't even matter...it's all true.<BR><BR>That was the easy one.<BR><BR>******************<BR><BR>NOW let's say that<BR> strSomething = 9983<BR><BR>So *IS* strSomething <> 9983? NOPE! That's a big fat FALSE<BR>But then *IS* strSomething <> 9984? Yep! 9983<>9984! So that's true.<BR><BR>So we just converted<BR> if (strSomething <> 9983) OR (strSomething <> 9984) then<BR>to<BR> if (False) OR (True) then<BR>but when one is false and the other true, then OR says... the final answer is TRUE! So it's all TRUE.<BR><BR>***********************<BR><BR>One more.<BR><BR>NOW let's say that<BR> strSomething = 9984<BR><BR>So *IS* strSomething <> 9984? Yep. That's true.<BR>And then *IS* strSomething <> 9984? *NO*! NO! 9984<>9984 is FALSE!<BR><BR>So we just converted<BR> if (strSomething <> 9983) OR (strSomething <> 9984) then<BR>to<BR> if (True) OR (False) then<BR>but when one is false and the other true, then OR says... the final answer is TRUE! So it's all TRUE.<BR><BR>*********************<BR><BR>IN OTHER WORDS...<BR><BR>No matter WHAT value strSomething has, your test will *ALWAYS* find ONE (or both) of the separate conditions TRUE and so the entire test is TRUE!<BR><BR>*************<BR><BR>Dare I suggest that this is likely NOT what you wanted???<BR><BR>Maybe you wanted to use AND instead of OR?<BR><BR><BR><BR><BR>

RE: Pretend you are a computer.
Hmmm, obviously I wasn't thinking like a computer, and even if I was trying to, I wouldn't have been able to figure that out because I don't think I would have ever guessed that was the way it thought. Sort of like a woman. I have to put that one in my Men are from Mars, Computers are from Venus" notebook. :)<BR><BR>Thanks again Bill. Just put it on my tab. Man that tab is getting long!

I used to teach 6th graders...
...a beforeschool computer programming class.<BR><BR>We only had 3 or 4 computers, so we kept the class size down, so I got to do it several times. (These are kids who came to school 45 minutes early...at 7:10 AM...to learn programming in 6th grade!)<BR><BR>Anyway, first class with each new group I gave a little quiz to see who already knew what. And one of the questions was *always*:<BR><BR>Q: How smart is a computer?<BR> a) as smart as I am<BR> b) smarter than I am<BR> c) as smart as my dog<BR> d) as smart as a rock<BR> e) other<BR><BR>And of course the correct answer is (d). Computers don't THINK at all, actually. Computers just follow the very most basic instructions. One very very very tiny step at a time. So I guess when I say "pretend you are a computer", I'm really saying "pretend you are a person who designs computer languages".<BR><BR>Anyway, for the last 55+ years, the rule for AND and OR operators have been the same, across hundreds of kinds of computers and hundreds of different computer languages.<BR><BR>True OR True >> True<BR>True OR False >> True<BR>False OR True >> True<BR>False OR False >> False<BR><BR>True AND True >> True<BR>True AND False >> False<BR>False AND True >> False<BR>False AND False >> False<BR><BR><BR>
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

