![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Location: India
Posts: 19
|
Dear Sir,
If I write a statement like the following: var = False AND msgbox("ANDstORy") or a statement like the following: val = True OR msgbox("ANDstORy") in each case the outcome is a MessageBox conting the given message. My question is, is not it a but of VB/VBA handling with the AND and OR operators? Or am I going wrong? Please show me a light. Because in some cases I have no other way besides writing an If-Else ladder with so many indents. Even I am quite wondered to see that the Iif() function also does not work as expected. It works like the same as stated above. i.e. the following statement: var = Iif(True, 1, msgbox("ANDstORy")) also shows the MessageBox containing the the given messages. What is going on? If it is a but then why Microsoft is not going to rectify it? If I am going wrong then please explain why? Thanks. |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: Essex, England
Posts: 458
|
I don't claim to be an expert at this sort of thing and I could well be misunderstanding you, but I'm not sure that you're using the AND/OR statements correctly. I've only seen them used in conjuction with some kind of logical test ie IF (logical test) AND/OR (logical test) THEN...
The Iif() problem I think is due to excel always evaluating both parts of the statement, even though it only needs one - I belive this is why your msgbox is appearing even though it is on the False part of the expression. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|