Solved

IF statement condition expression - order of evaluation

Posted on 2006-06-23
3
785 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

760 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