Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Select Case mistake
#11
(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.
Reply
#12
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.
Reply
#13
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
Reply
#14
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.
Shoot first and shoot people who ask questions, later.
Reply
#15
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
Reply
#16
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
Reply
#17
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.
Reply
#18
Nice. For further reference, we had discussion about SELECT EVERYCASE in this thread as well: https://qb64phoenix.com/forum/showthread...04#pid9304

Pete
Reply
#19
@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.
Reply




Users browsing this thread: 3 Guest(s)