LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Bizzare behavior of IF..THEN


Having in times past encountered very freakish behavior of IF...THE
clauses, I now wish to bring up some of my observations for commen
and possible explanation. Below are 4 trumped-up cases each showin
the evaluation, or lack of it, of the conditions set out in eac
routine. Cases A and B are straightforward as they conform to what w
might expect. Namely, there is indication of serial evaluation of al
the conditions- whether met or not.

By contrast, Cases C and D betray the norm, at least seemingly so, a
conditions which should be positively evaluated appear to be untouched
(see the commented annotations for full appreciation).

Case A Case B
'all 4 conds evaluated 'all 4 conds evaluated
Sub test2() Sub test3()
If 4 < 5 Then If 4 < 5 Then 'evaluated
MSGBOX [/b]\"4<5\" *MSGBOX *\"4<5\"
IF 4 3 THEN END IF
*MSGBOX *\"43\" IF 8 10 THEN 'EVALUATED
IF 4 = 4 THEN MSGBOX \"810\"
*MSGBOX *\"4=4\" END IF
ELSE IF 3 = 3 THEN 'EVALUATED
MSGBOX \"OTHER\" *MSGBOX* \"3=3\"
END IF ELSE 'EVALUATED
END IF MSGBOX \"OTHER\"
END IF END IF
END SUB END SUB


CASE C CASE D
* 'NONE IS EVALUATED INCLUDING COND
Sub test1() Sub test4()
If 4 < 5 Then 'evaluated If 12 < 5 Then
MSGBOX* \"4<5\" MSGBOX \"12<5\"
IF 8 10 THEN*'NOT EVALUATED* IF 8 10 THEN
MSGBOX \"810\" MSGBOX \"810\"
IF 3 = 3 THEN *'NOT EVALUATED* IF 3 = 3 THEN *'NOT EVALUATE
MsgBox "3=3" MsgBox "3=3"
Else [b]'not evaluated* Else
MsgBox "other" MsgBox "other"
End If End If
End If End If
End If End If
End Sub End Sub

Bolded MsgBox refers to positive evaluation as it springs to life.

Your comments are welcomed.

Myle

--
Myle
-----------------------------------------------------------------------
Myles's Profile: http://www.excelforum.com/member.php...fo&userid=2874
View this thread: http://www.excelforum.com/showthread.php?threadid=50665

 
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
odd behavior Rich[_8_] Excel Discussion (Misc queries) 2 November 20th 08 10:02 PM
Very odd behavior Kim K Excel Discussion (Misc queries) 2 May 7th 07 12:41 PM
I'm having a bizzare problem with C&P!!!! Marc New Users to Excel 6 April 24th 05 06:29 PM
odd behavior marwan hefnawy Excel Programming 0 September 21st 04 05:15 AM
Bizzare issue with matrix calculations ajames54 Excel Programming 3 February 10th 04 03:29 AM


All times are GMT +1. The time now is 07:35 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"