Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
How to evaluate 2 expressions?
Old 05-24-2007, 06:41 PM How to evaluate 2 expressions?
webgrrl's Avatar
Skilled Talker

Posts: 74
Trades: 0
I am trying to evaluate 2 expressions. What is the best way to do this?

Could I use an If...Then statement, like this?
If (FirstVar >= 1) AND (FirstVar <= 500) Then
Response.Write "The first variable is fairly small"
End If
Can I use a Do...While statement, like this?
Do While (varCounter <= FirstVar) AND (FirstVar <= 500)
varCounter = varCounter + 100
Loop
If these are not good, then what should I use instead? Please help!

Thanks,
WebGrrl
webgrrl is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-24-2007, 07:04 PM Re: How to evaluate 2 expressions?
ExpressoDan's Avatar
Ultra Talker

Posts: 317
Name: This Space for Rent
Location: Georgia
Trades: 0
It depends on what you want to evaluate and the amount of variables your trying to evaluate. Can you be a little more specific?

Either example there could work, but it depends on what you're trying to do.
__________________

Please login or register to view this content. Registration is FREE

"I think therefore I am, I think." <!-- George Carlin
ExpressoDan is offline
Reply With Quote
View Public Profile Visit ExpressoDan's homepage!
 
Old 05-24-2007, 07:26 PM Re: How to evaluate 2 expressions?
webgrrl's Avatar
Skilled Talker

Posts: 74
Trades: 0
I'm trying to see if a number is between two numbers. I realize that I can only evaluate one expression at a time (i.e., I know that I can't do this: y > z > 4).

My asp book says that If...Then statements can only evaluate one expression, but the code seems to work, so I am wondering if the code is inefficient? Is there a better way to evaluate 2 expressions?

Thanks,
WebGrrl
webgrrl is offline
Reply With Quote
View Public Profile
 
Old 05-25-2007, 01:18 PM Re: How to evaluate 2 expressions?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
The first example would be efficient

an IF statement can only evalute a single expression but as you can see expressions can be joined with logical operators (AND, OR, XOR) and paranthesis can be used for the evaluation order

it's ((y > z) and (z > 4)) BTW If my boolean algebra is up to speed
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-25-2007, 07:36 PM Re: How to evaluate 2 expressions?
webgrrl's Avatar
Skilled Talker

Posts: 74
Trades: 0
Ahhh, thank you, good to know.

WebGrrl
webgrrl is offline
Reply With Quote
View Public Profile
 
Old 05-26-2007, 04:50 PM Re: How to evaluate 2 expressions?
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
You don't need the brackets at all in your particular if statement, as in most if statements. The only time you need them is if you're comparing using different logical operators and you need to group them.

For example:

if FirstVar >= 1 and FirstVar <= 500 then

would be sufficient.

However, let's say you wanted to see if your number fell within one of two ranges:

if FirstVar >=1 and FirstVar <=500 or FirstVar >= 1000 and FirstVar <=5000 then

That wouldn't work because it would look for a number that was at least 1000 and no more than 500. There's no such animal.

That's where you need the brackets.

if (FirstVar >=1 and FirstVar <=500) or (FirstVar >=1000 and FirstVar <=5000) then

This would search for a number that's either between 1 and 500 or between 1000 and 5000.

This is rather abstract and confusing at first, but once you use the brackets a few times it will make some sense.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 06-03-2007, 11:33 PM Re: How to evaluate 2 expressions?
Novice Talker

Posts: 13
Trades: 0
Use the IF statement. Do-WHILE is for looping and what you have it not a loop.
brucec is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to evaluate 2 expressions?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26319 seconds with 12 queries