Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
In Terms of Best Practices with Else and ElseIf
#1
Found I have gone back to some old Qbasic routines to copy paste into present day code I've been working on and notice back then I never did use ElseIf but rather Else with IF in the following line, for example .

Code: (Select All)
a = 10
b = 12
c = 22
d = 60
If (a + b / 2) = c Then
    Print "Correct"
Else
    If (a + b * 2) = d Then
        Print "Correct"
    Else
        Print "Incorrect"
    End If
End If

Like the old adage goes, if its not broke don't fix it but, other than Elseif working better with the THEN and a block of code, would you classify code which uses Else with an IF on the following line as ok in terms of not worth the effort to change it?
Reply


Messages In This Thread
In Terms of Best Practices with Else and ElseIf - by Dimster - 10-26-2025, 05:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Good Coding with ElseIF Dimster 12 2,295 05-05-2023, 08:37 PM
Last Post: bplus

Forum Jump:


Users browsing this thread: 1 Guest(s)