Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Good Coding with ElseIF
#7
(05-04-2023, 09:23 PM)James D Jarvis Wrote: Or maybe use Select Case?

Code: (Select All)
For i = 1 To 15
    a$ = Str$(i)
    Select EveryCase i
        Case Is > 5
            a$ = a$ + " " + Str$(i * 2)
        Case Is > 10
            a$ = a$ + " " + Str$(i * 3)

    End Select
    Print a$
Next i

This is only an example I've provided. "EVERYCASE" is confusing and isn't supported by many modern BASIC's. Let's see what Dimster has to say about it. Otherwise he wants to be convinced about which block is better, a single long clause involving "ELSEIF", or "ELSE" section which has its own "IF" block. "SELECT CASE... END SELECT" could help even with multiple variables involved but could get ornery, might have to put specific code sections into a subprogram, perhaps with shared variables to make all the code easier to read.
Reply


Messages In This Thread
Good Coding with ElseIF - by Dimster - 05-04-2023, 04:11 PM
RE: Good Coding with ElseIF - by mnrvovrfc - 05-04-2023, 04:45 PM
RE: Good Coding with ElseIF - by Dimster - 05-04-2023, 07:22 PM
RE: Good Coding with ElseIF - by mnrvovrfc - 05-04-2023, 09:12 PM
RE: Good Coding with ElseIF - by James D Jarvis - 05-04-2023, 09:23 PM
RE: Good Coding with ElseIF - by TerryRitchie - 05-04-2023, 09:51 PM
RE: Good Coding with ElseIF - by James D Jarvis - 05-05-2023, 01:39 AM
RE: Good Coding with ElseIF - by mnrvovrfc - 05-04-2023, 10:09 PM
RE: Good Coding with ElseIF - by James D Jarvis - 05-05-2023, 01:35 AM
RE: Good Coding with ElseIF - by Dimster - 05-05-2023, 01:03 PM
RE: Good Coding with ElseIF - by bplus - 05-05-2023, 05:38 PM
RE: Good Coding with ElseIF - by Dimster - 05-05-2023, 08:11 PM
RE: Good Coding with ElseIF - by bplus - 05-05-2023, 08:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  In Terms of Best Practices with Else and ElseIf Dimster 1 282 10-26-2025, 05:41 PM
Last Post: bplus
  Good MacOs Font? BlameTroi 5 952 05-23-2025, 05:31 PM
Last Post: bplus
  anyone good at javascript want to help convert a cool animation to QB64PE? madscijr 10 1,375 05-21-2025, 09:47 PM
Last Post: hsiangch_ong
  What good is cake if you can't eat it too? Pete 2 885 02-21-2025, 04:35 AM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)