View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Bizzare behavior of IF..THEN

On Tue, 31 Jan 2006 09:24:36 -0600, Myles
wrote:


Hi Ron,

you wrote inter alia:
If you want it to do further testing if a test is false, then you need
to make doing those tests a consequence of the false result.


Since the code exits upon encountering a FALSE evaluation, could you
please give an illustration of how you can base your tests on -a
consequence of the false result-


Thanks

Myles


You need to use the proper syntax. Using either Else or ElseIF for the nested
testing. (See HELP for the IF...Then...Else Statement)

============================
Sub fooD()
If 12 < 5 Then
MsgBox ("12<5")
Else
If 8 10 Then
MsgBox ("810")
Else
If 3 = 3 Then
MsgBox ("3=3")
Else
MsgBox ("other")
End If
End If
End If

End Sub
=============================

This now displays in the message box "3=3"

Or, using the Elseif:

==================================
Sub fooD()

If 12 < 5 Then
MsgBox ("12<5")
ElseIf 8 10 Then
MsgBox ("810")
ElseIf 3 = 3 Then
MsgBox ("3=3")
Else
MsgBox ("other")
End If

End Sub
=================================


--ron