Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

IF statement condition expression - order of evaluation

Posted on 2006-06-23
3
Medium Priority
?
806 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 66

Accepted Solution

by:
Jim Horn earned 500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

618 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