No announcement yet.

Select Case with AND ?

  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    To answer the original question you could use;

    Dim x As Integer
    For x = 1 To 26   ' for loop only added to show how each result is handled.
       Select Case x
       Case 6 To 11, 18 To 24, 26
                   ? "case 1"
            Case Else
                    ? "case else"
       End Select
    Next x
    is the acceptable way on the DOS version for a range test. opc1:
    Last edited by Scott Slater; 30 Jun 2009, 04:29 PM. Reason: fixed code
    Scott Slater
    Summit Computer Networks, Inc.


    • #22
      >is the acceptable way on the DOS version for a range test

      And so it it is...except the original question was not about a 'range'... it was..
      Can I make a SELECT CASE statement using the logical AND?? I.e., can I do this:?
      Unfortunately, the "this" demonstrated a set of multiple AND-connected conditions which just happened to be re-arrangeable into a range test.

      That much-harped-upon need for 'communications skills' just keeps turning up everywhere, doesn't it?

      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]


      • #23
        The answer (according to PB DOS manual) would be more or less NO.

        from PB DOS 3.5 Manual:
        The test which may be performed by a CASE clause include equality, in equality, greater than, less than, and range("from-to") testing. Examples of CASE clause tests include:

        CASE > b
        CASE 14
        CASE b TO 99
        CASE 14, b
        CASE 25 TO 99, 14

        When a CASE clause contains multiple tests separated by commas, a logical OR is performed. That is, if any one (or more) of the tests is TRUE, the entire clause is TRUE.
        If you want multiple AND tests, it looks like you'd have to resort to the IF BLOCK.
        Scott Slater
        Summit Computer Networks, Inc.