Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Select Case mistake
#6
(11-07-2022, 09:41 PM)Pete Wrote: This looks like a job for SELECT CASES Which we don't have. Sad

From my other thread: https://qb64phoenix.com/forum/showthread...LECT+CASES

We have a split between devs on putting it into QB64 so who knows, maybe someday.

Anyway, don't get fooled by whatever the heck this is...

Code: (Select All)
a = 1600
SELECT CASE a
    CASE IS > 500, IS < 700
        PRINT "Wrong!"
END SELECT

Funny it looks like it should work, but of course it won't; but I find it curious we can divide up CASE statements with commas like this. So I don't get the logic here. This sample will print "Wrong!" when it should print nothing, as 1600 is > 500 but NOT smaller than 1600 to satisfy an a > 500 AND a < 700, BUT AGAIN, no "AND" SO THIS IS NOT WHAT THE CODE IS SET UP TO DO. So what is the comma use is set up to do? I'd have to go research that a bit to figure it out. I just thought I'd bring it up for the fun of it. I just use what mn demonstrated when I need these SELECT CASES (we don't have) situations.

Did I mention we don't have SELECT CASES?

Pete

We don't have SELECT CASES, varmint!

AS I mentioned:  It works as an OR comparison.  Think of it as:

SELECT CASE 1, 2, 3, 5, 7, 9

^The above is for 1 OR 2 OR 3 OR 5 OR 7 OR 9....

SELECT CASE IS > 50, IS < 70 is basically IF whatever > 50 OR whatever < 70 THEN....   

It's basically bad programmer logic which is going to be true all the time, but it *is* a valid syntax.  Tongue



What we need is an AND IS statement.

CASE IS > 50, AND IS < 70
Reply


Messages In This Thread
Select Case mistake - by Kernelpanic - 11-07-2022, 09:09 PM
RE: Select Case mistake - by mnrvovrfc - 11-07-2022, 09:19 PM
RE: Select Case mistake - by SMcNeill - 11-07-2022, 09:35 PM
RE: Select Case mistake - by SMcNeill - 11-07-2022, 09:29 PM
RE: Select Case mistake - by Pete - 11-07-2022, 09:41 PM
RE: Select Case mistake - by SMcNeill - 11-07-2022, 09:45 PM
RE: Select Case mistake - by Pete - 11-07-2022, 09:52 PM
RE: Select Case mistake - by mnrvovrfc - 11-07-2022, 10:14 PM
RE: Select Case mistake - by Pete - 11-07-2022, 10:20 PM
RE: Select Case mistake - by mnrvovrfc - 11-07-2022, 10:27 PM
RE: Select Case mistake - by Kernelpanic - 11-07-2022, 10:21 PM
RE: Select Case mistake - by Kernelpanic - 11-07-2022, 10:36 PM
RE: Select Case mistake - by Kernelpanic - 11-08-2022, 02:57 PM
RE: Select Case mistake - by Pete - 11-08-2022, 03:28 PM
RE: Select Case mistake - by SMcNeill - 11-08-2022, 03:58 PM
RE: Select Case mistake - by Pete - 11-08-2022, 04:17 PM
RE: Select Case mistake - by Kernelpanic - 11-08-2022, 04:21 PM
RE: Select Case mistake - by Pete - 11-08-2022, 04:28 PM
RE: Select Case mistake - by Kernelpanic - 11-08-2022, 04:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Testing against multiple elements at a time without select case CMR 4 848 04-17-2025, 02:16 AM
Last Post: CMR
  Select Case error Dimster 9 1,803 12-15-2023, 03:00 PM
Last Post: SpriggsySpriggs
  Where is my mistake using _mousemovement keywords? TempodiBasic 8 1,624 09-26-2023, 10:11 PM
Last Post: TempodiBasic
  Is Select All not working? PhilOfPerth 13 2,496 08-01-2022, 12:17 AM
Last Post: bplus
  Help with Select Case PhilOfPerth 5 1,362 04-24-2022, 07:54 AM
Last Post: PhilOfPerth

Forum Jump:


Users browsing this thread: 1 Guest(s)