Solved

IF statement condition expression - order of evaluation

Posted on 2006-06-23
3
793 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JSON Response and request in VB6 application 11 811
using web browser with BING 40 136
checkbox to hide entire section 10 62
Set WorkSheet  not Working 9 51
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 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