atesh Posted August 20, 2003 Posted August 20, 2003 What's the best way to write the following: If a = b Or a = c Or a = d Or a = e Then ... Quote To err is human, to really foul things up requires a computer.
*Experts* Volte Posted August 20, 2003 *Experts* Posted August 20, 2003 Nothing wrong with that, except you should use the logic OrElse operator.If a = b OrElse a = c OrElse a = d OrElse a = e Then Quote
Diablicolic Posted August 21, 2003 Posted August 21, 2003 Why OrElse other than Or? :( Quote "Reality is fake, Dreams are for real"
*Experts* Volte Posted August 21, 2003 *Experts* Posted August 21, 2003 Or is for boolean math, OrElse is for logical comparison. It's basically Or in VB is | in C++, and OrElse in VB is || in C++. I believe it will evaluate each expression individually and if it is false, it'll evaluate the next one, and if it's true it'll go right into the If block. Quote
Diablicolic Posted August 21, 2003 Posted August 21, 2003 ..hmm...so orelse is faster than or? Quote "Reality is fake, Dreams are for real"
Moderators Robby Posted August 21, 2003 Moderators Posted August 21, 2003 As well you can use the new AndAlso. It behaves somewhat like OrElse, if the first condition is false it stops evaluating. Quote Visit...Bassic Software
Moderators Robby Posted August 21, 2003 Moderators Posted August 21, 2003 Yes they are both faster because they only evaluate until the condition is not met. Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.