Visualizzazione dei risultati da 1 a 4 su 4

Discussione: if then

  1. #1
    Utente di HTML.it
    Registrato dal
    Dec 2003
    Messaggi
    194

    if then

    come si specifica un valore comreso
    es con maggiore e minore va tutto bene

    codice:
    <%
    If bottiglie <6  Then
    costi=9
    
    ElseIf bottiglie >7   Then
    costi=10
    
    End If
    %>
    ma se volessi fare cosi non va

    codice:
    <%
    If bottiglie <6  Then
    costi=9
    
    ElseIf bottiglie >7 and <12  Then
    costi=10
    
    ElseIf bottiglie >13 and <18  Then
    costi=14
    
    ElseIf bottiglie >19 and <36  Then
    costi=18
    
    ElseIf bottiglie >37 and <72  Then
    costi=25
    
    End If
    %>
    la pagina va in errore è sbagliato come è scritto?
    come si dice che bottiglie è compreso tra due valori?

  2. #2
    Utente di HTML.it
    Registrato dal
    Apr 2000
    Messaggi
    938
    Ciao



    Prova cosi


    ElseIf bottiglie >7 and bottiglie <12 Then
    costi=10


    Massimo

  3. #3
    Utente di HTML.it
    Registrato dal
    Dec 2003
    Messaggi
    194
    non funziona correttamente, cioè se ho 20 bottiglie, mi restituisce la seconda condizione
    ElseIf bottiglie >7 and bottiglie <12 Then
    costi=10

    perchè 20 pè maggiore di 7 quindi mi restituisce 10 euro e non 18

    codice:
    <%
    If bottiglie <6  Then
    costi=9
    
    ElseIf bottiglie >7 and bottiglie <12  Then
    costi=10
    
    ElseIf bottiglie >13 and bottiglie <18  Then
    costi=14
    
    ElseIf bottiglie >19 and bottiglie <36  Then
    costi=18
    
    ElseIf bottiglie >37 and bottiglie <72  Then
    costi=25
    
    End If
    %>

  4. #4
    Utente di HTML.it
    Registrato dal
    Apr 2000
    Messaggi
    938
    Ciao


    Prova a togliere gli elseif ed usare solo if chiudendo ogni singola condizione con end if


    <%
    If bottiglie <6 Then
    costi=9

    If bottiglie >7 and bottiglie <12 Then
    costi=10
    end if
    If bottiglie >13 and bottiglie <18 Then
    costi=14
    end if
    If bottiglie >19 and bottiglie <36 Then
    costi=18
    end if
    If bottiglie >37 and bottiglie <72 Then
    costi=25
    end if
    End If
    %>


    <%
    If bottiglie <6 Then
    costi=9
    end if

    fai una prova chiudendo subito anche questa
    e non alla fine


    Massimo

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 © 2025 vBulletin Solutions, Inc. All rights reserved.