Please help to understand this CASE statement

Discussion in 'Visual Basic ( VB )' started by regressist, Apr 22, 2022.

  1. regressist

    regressist New Member

    Joined:
    Apr 19, 2022
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    1
    Gender:
    Male
    Hi all and sorry for what is probably a very stupid question. I am trying to translate in Pascal a program written in BASIC and I am stuck with a statement for which I do not find any documentation: the statement is

    Select Case X
    Case 21, 24, 25, 27 To 32, 34, 35, 38
    etc.

    I know e.g. Case a To b, but I am puzzled by the multiple ranges which I do not know how to understand!

    Thanks in advance to whomever will reply

    P.S. For your info the full statement is
    Code:
    Select Case X
    Case 21, 24, 25, 27 To 32, 34, 35, 38
    temp = temp - 1
    Case 33, 36, 37, 39, 40
    temp = temp - 2
    End Select
    
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,367
    Likes Received:
    386
    Trophy Points:
    83
    Code:
    Case 21, 24, 25, 27 To 32, 34, 35, 38
    it means when X is equial to 21, 24, 25, 27, 28, 29, 30, 31 32, 34, 35, 38
     
  3. regressist

    regressist New Member

    Joined:
    Apr 19, 2022
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    1
    Gender:
    Male
    thanks, so it must be read as

    Case 21, 24, 25, (27 To 32), 34, 35, 38
     
  4. regressist

    regressist New Member

    Joined:
    Apr 19, 2022
    Messages:
    3
    Likes Received:
    1
    Trophy Points:
    1
    Gender:
    Male
    Thank you again, it works perfectly
     
    shabbir likes this.
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,367
    Likes Received:
    386
    Trophy Points:
    83
    The pleasure is all mine.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice