DAY 041: ELSEIF
#3
One thing of note here:  ELSEIF is not the same as ELSE IF.  Some folks think they're the same thing, just formatted slightly different for readability.  They're not!

ELSEIF is a continuation of an existing IF statement, offering a different option to the previous choices.  ELSE IF is a completely new and unrelated IF statement, with no regard to the first beyond the fact that it occurs IF they previous conditions don't occur.

A segment of code will probably highlight the difference between the two better than I could explain:

Code: (Select All)
If a Then
    Print a
ElseIf b Then
    Print b
ElseIf c Then
    Print c
Else
    Print d
End If

If a Then
    Print a
Else If b Then
        Print b
    Else If c Then
            Print c
        Else
            Print d
        End If
    End If
End If


Notice the number of END IFs needed in both versions.  They're definitely not the same command!
Reply


Messages In This Thread
DAY 041: ELSEIF - by Pete - 12-21-2022, 02:29 AM
RE: DAY 041: ELSEIF - by mnrvovrfc - 12-21-2022, 04:08 PM
RE: DAY 041: ELSEIF - by SMcNeill - 12-22-2022, 01:55 AM
RE: DAY 041: ELSEIF - by Pete - 12-22-2022, 02:05 AM



Users browsing this thread: 3 Guest(s)