Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Does VBA shortcut "or" statements?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
baobob@my-deja.com - 14 Mar 2008 09:13 GMT
Thanks.

***
Peter T - 14 Mar 2008 10:02 GMT
Explain the question

Regards,
Peter T

> Thanks.
>
> ***
Chip Pearson - 14 Mar 2008 23:17 GMT
> Explain the question

Shortcutting in this context means that, for example, the right operand of
an OR operation is not evaluated if the left operand is True. Logically,
shortcutting makes sense, because if the left operand is True, there is no
need to evaluate the right operand since the OR is True regardless of the
value of the right operand.

No, VB/VBA does not shortcut operations.

Signature

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
   Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

> Explain the question
>
[quoted text clipped - 4 lines]
>>
>> ***
Peter T - 14 Mar 2008 23:53 GMT
I kind of suspected that was what the OP meant but didn't want to second
guess a reply.

Although logically it might seem as though evaluating the right operand is
redundant if the left is true, I assume it always evaluates both as Or works
by doing a Bitwise comparison of the pair.

v = -1 Or -1
v = -1 Or True
v = True Or 0
the above all return -1 but the following returns True.
v = True Or True

Regards,
Peter T

> > Explain the question
>
[quoted text clipped - 12 lines]
> >
> > <baobob@my-deja.com> wrote in message

news:a50772e9-0859-45b6-8877-b6cc001f09ca@x41g2000hsb.googlegroups.com...
> >> Thanks.
> >>
> >> ***
Rick Rothstein (MVP - VB) - 14 Mar 2008 10:32 GMT
No... in expressions containing logical operators (And, Or, Xor, etc.), VB
evaluates every sub-expression even if the first one's evaluation would be
enough to determine the expression's value as a whole.

Rick

> Thanks.
>
> ***
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.