Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Using Or and And Operators

Can someone tell me why If statement below equates to True? I really need to
know how the computer reads this expression. I thought the computer reads it
from left to right, like this:

True Or False = TRUE
Then
TRUE And False = False

but, the computer says I'm wrong, why? How should I read this If Statement?

If True Or False And False Then
msgbox "Do Something"
End If
--
Cheers,
Ryan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Using Or and And Operators

It is always best to use parethesis to make sure calcuations are done in the
order you want. See VBA Help under PRECEDENCE for full explaination.
Basically the AND is done before the OR so you have

True Or (False And False)
True or False
True


"RyanH" wrote:

Can someone tell me why If statement below equates to True? I really need to
know how the computer reads this expression. I thought the computer reads it
from left to right, like this:

True Or False = TRUE
Then
TRUE And False = False

but, the computer says I'm wrong, why? How should I read this If Statement?

If True Or False And False Then
msgbox "Do Something"
End If
--
Cheers,
Ryan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Using Or and And Operators

Thats what I needed. Thanks!
--
Cheers,
Ryan


"Joel" wrote:

It is always best to use parethesis to make sure calcuations are done in the
order you want. See VBA Help under PRECEDENCE for full explaination.
Basically the AND is done before the OR so you have

True Or (False And False)
True or False
True


"RyanH" wrote:

Can someone tell me why If statement below equates to True? I really need to
know how the computer reads this expression. I thought the computer reads it
from left to right, like this:

True Or False = TRUE
Then
TRUE And False = False

but, the computer says I'm wrong, why? How should I read this If Statement?

If True Or False And False Then
msgbox "Do Something"
End If
--
Cheers,
Ryan

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
combining operators ezil Excel Programming 3 July 23rd 07 06:46 PM
Operators/if etc Peter[_61_] Excel Programming 4 December 18th 06 11:11 AM
Where are Bitwise Operators Dennis W. Bulgrien Excel Worksheet Functions 1 June 30th 06 05:51 PM
Operators With Times Michael Link Excel Discussion (Misc queries) 2 March 9th 05 02:46 PM
Unary operators Joe Excel Worksheet Functions 3 February 14th 05 06:09 PM


All times are GMT +1. The time now is 01:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"