Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using _Andalso with Select Case
#2
select case... end select wasn't designed for the application you described.  what is the fear of using ordinary if... then... else... end if block?

select case was created in a time.  where it looked like basic would never offer short-circuit evaluation.  while it's offered in qb64pe.  it has to be only in if... then... else... end if block.  otherwise it would be confusing.  i don't think other programming languages are different about it.  although i've seen c code that is simply mind-boggling.

could do something like this:

Code: (Select All)
a = 4
input b
if a = 4 _andalso b = 5 then
    'do this
else
    do
        select case a
            case 5, 10, 15
                print "It's divisible by five!"
                exit do
        end select
        select everycase b
            case 1
                print "The other value is too low."
            case 5
                print "b was expected to be this value."
            case 1 to 5
                print "It was part of the stupid test!"
        end select
    loop until 1
end if
put select case... end select inside an if... then... else... end if block.  use the compound operators in the "if" statement.  note how the do... loop is being used, it executes only once.  this is only to be able to use exit do to ignore other statements after it.  in case the programmer doesn't want them executed for a specific case.  this could be looked up in the qb64 wiki.
Reply


Messages In This Thread
Using _Andalso with Select Case - by Dimster - 05-21-2025, 03:48 PM
RE: Using _Andalso with Select Case - by hsiangch_ong - 05-21-2025, 09:38 PM
RE: Using _Andalso with Select Case - by Dimster - Yesterday, 12:43 PM



Users browsing this thread: 1 Guest(s)