QB64 Phoenix Edition
Select Case mistake - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: Select Case mistake (/showthread.php?tid=1070)

Pages: 1 2


RE: Select Case mistake - mnrvovrfc - 11-07-2022

(11-07-2022, 10:20 PM)Pete Wrote: Yep, you're very much the Chatty Cathy around these parts, that's for sure. Hey, is that Cathy with a "C" or Kathy with a "K" do you suppose?
Sometimes I feel like Guisewite. No I didn't like that cartoon strip but...

@Kernelpanic you will have to remove altogether the "CASE IS > 5500" and in the "CASE ELSE", test for your "VW Polo", allowing nothing else higher than 7000.


RE: Select Case mistake - Kernelpanic - 11-07-2022

Quote:@Kernelpanic you will have to remove altogether the "CASE IS > 5500" and in the "CASE ELSE", test for your "VW Polo", allowing nothing else higher than 7000.

Yes, I tried that too, but I want to show the difference between Select Case and Select EveryCase.


RE: Select Case mistake - Kernelpanic - 11-08-2022

I've tried everything again, but it doesn't work; I noticed that with the comma also yesterday.
"Or" seems really redundant since it doesn't seem to do anything. An "And Less" would be good: Case Is > 5500.00 And Less 7000.00 - Case Is > 5500.00 And 7000.00 <

This would work in the sample program (Select Case):
Available (purchase price) up to 6100.00 -> VW Polo
Available (purchase price) up to 7100.00 -> (Case Else) Not on offer


RE: Select Case mistake - Pete - 11-08-2022

Code: (Select All)
'This would work in the sample program (Select Case):
'Available (purchase price) up to and including 6100.00 -> VW Polo
'Available (purchase price) up to and including 7100.00 -> (Case Else) Not on offer

CLS
INPUT "Purchase Price: "; purchase_price
SELECT CASE purchase_price
    CASE IS <= 6100.00
        PRINT "VW Polo."
    CASE 6100.01 TO 7100.00
        PRINT "6100.01 TO 7100.00"
    CASE ELSE
        PRINT "Not an offer"
END SELECT
SLEEP
RUN ' Try another price.



RE: Select Case mistake - SMcNeill - 11-08-2022

Is this basically what you're looking for?

Code: (Select All)
'Beispiel fuer Select Case und EveryCase - 7. Nov. 2022

Option _Explicit

Dim As Double kaufpreis

Print "Gebrauchtwagenkauf"
Print
Input "Wieviel moechten Sie ausgeben? ", kaufpreis

Print "Select Case:"
Select Case kaufpreis
    Case 4000 To 5000
        Print "Trabant, blau, frisiert - 31 KW."
    Case 5000 To 6000
        Print "Wartburg, dunkelgruen, 74.00 KM, 40 KW."
    Case 5500 To 7000
        Print "VW Polo, beige, 110.000 KM, 44 KW"
    Case Else
        Print "Haben wir leider nicht im Angebot!"
End Select

Print
Print "Select EveryCase:"
Select EveryCase kaufpreis
    Case 4000 To 5000
        Print "Trabant, blau, frisiert - 31 KW."
    Case 5000 To 6000
        Print "Wartburg, dunkelgruen, 74.00 KM, 40 KW."
    Case 5500 To 7000
        Print "VW Polo, beige, 110.000 KM, 44 KW"
    Case Else
        Print "Haben wir leider nicht im Angebot!"
End Select

End



RE: Select Case mistake - Pete - 11-08-2022

I wish Musk would hurry up and invent the Universal translator. Honestly, the Kernel must struggle with the language here a lot, and I can't imagine how the guys from Australia can even keep up. Huh

Pete


RE: Select Case mistake - Kernelpanic - 11-08-2022

Quote:Is this basically what you're looking for?

Yes! With Select EveryCase, a buyer would see all the offers that are within their price range. With Select Case, only what comes first.


RE: Select Case mistake - Pete - 11-08-2022

Nice. For further reference, we had discussion about SELECT EVERYCASE in this thread as well: https://qb64phoenix.com/forum/showthread.php?tid=1061&pid=9304#pid9304

Pete


RE: Select Case mistake - Kernelpanic - 11-08-2022

@Pete - The example works like this, but in practice you only have one choice.

PS: I know the thread, it was the suggestion for my example.