Visualizzazione dei risultati da 1 a 9 su 9
  1. #1
    Utente di HTML.it L'avatar di eng
    Registrato dal
    Mar 2002
    Messaggi
    1,227

    select case con operatori logici

    ciao a tutti,
    vorrei sapere se nella struttura

    Selcet case espressione
    case valore1

    case valore2



    else

    End Select

    posso usare come valoreX anche un'espressione booleana valore1 or valore2

    Penso di no, ma non volevo usare al poso del select-case strutture if-then-else
    grazie
    ciao
    EnG

  2. #2
    Utente di HTML.it L'avatar di eng
    Registrato dal
    Mar 2002
    Messaggi
    1,227

    soluzione

    fortunatamente mi sbagliavo: si può fare.
    Posto la soluzione per chi in futuro, come ora a me, avrà bisogno.

    http://www.cs.mtu.edu/~shene/COURSES...03/select.html

    in particolare:

    If the value of c is one of the first ten letters (in lower case), 'One of the first ten letters' is displayed; if the value of c is one of l, m, n, o, p, u, v, w, x, y, 'One of l, m, n, o, p, u, v, w, x, y' is displayed; if the value of c is one of z, q, r, s, t, 'One of z, q, r, s, t' is displayed; and if the value of c is none of the above, 'Other characters, which may not be letters' is displayed. In the last case, the value of c could be one of these lower case letters not listed, an upper case letters, a digit, an operator, or any other character. So, if you only want to handle lower case letters, this program is incorrect.
    CHARACTER(LEN=1) :: c

    SELECT CASE (c)
    CASE ('a' : 'j')
    WRITE(*,*) 'One of the first ten letters'
    CASE ('l' : 'p', 'u' : 'y')
    WRITE(*,*) 'One of l, m, n, o, p, u, v, w, x, y'
    CASE ('z', 'q' : 't')
    WRITE(*,*) 'One of z, q, r, s, t'
    CASE DEFAULT
    WRITE(*,*) 'Other characters, which may not be letters'
    END SELECT

    The following program uses the value of Number to determine the value of Range.
    INTEGER :: Number, Range

    SELECT CASE (Number)
    CASE ( : -10, 10 : )
    Range = 1
    CASE (-5:-3, 6:9)
    Range = 2
    CASE (-2:2)
    Range = 3
    CASE (3, 5)
    Range = 4
    CASE (4)
    Range = 5
    CASE DEFAULT
    Range = 6
    END SELECT

    Here is the result:

    Number Range Why?
    <= -10 1 CASE ( : -10, 10 : )
    -9, -8, -7, -6 6 CASE DEFAULT
    -5, -4, -3 2 CASE (-5:-3, 6:9)
    -2, -1, 0, 1, 2 3 CASE (-2:2)
    3 4 CASE (3, 5)
    4 5 CASE (4)
    5 4 CASE (3, 5)
    6, 7, 8, 9 2 CASE (-5:-3, 6:9)
    >= 10 1 CASE ( : -10, 10 : )

  3. #3
    non mi pare sia vbscript

  4. #4

  5. #5
    in vb classico si può fare

    select case valore
    case a,b

    dove la virgola rappresenta un OR

    ma mi pare che in vbscript la case accetti solo valori univoci

  6. #6
    Utente di HTML.it L'avatar di eng
    Registrato dal
    Mar 2002
    Messaggi
    1,227
    a me funziona bene

  7. #7
    In vbscript se non ricordo male puoi specificare elenchi di valori separati da virgola nei case, non però i range che invece puoi specificare in vb (ex 1 to 10).

    xxx

  8. #8
    Utente di HTML.it L'avatar di eng
    Registrato dal
    Mar 2002
    Messaggi
    1,227
    chiarissimo, tnx

  9. #9
    Originariamente inviato da eng
    a me funziona bene
    e postaci il codice

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.