Solved

IF statement condition expression - order of evaluation

Posted on 2006-06-23
3
786 Views
Last Modified: 2008-03-10
Team -

Does VB have an order of evaluation of a boolean conditional expression inside an IF statement? I have some code that appears to be evaluating both terms of an OR expression even though the first term evaluates to true.

Example for clarity -

IF ((x < 0) Or (functionCall(x)) Then
...

In most languages, if x < 0, the function functionCall is never called.

Is this true for VB, or does VB evaluate all terms in the conditional?

Thanks
bcote
0
Comment
Question by:blcote
  • 2
3 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 125 total points
ID: 16971951
I know that in Access VBA, it will evaluate both expressions, regardless of whether the first expression returns True, and I suspect Excel VBA behaves the same way.
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 16971961
yes vb also does...
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 16971966
* VB also evaluates all expressions even if the first is true
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now