Visualizzazione dei risultati da 1 a 5 su 5

Discussione: Somma in un FOR

  1. #1

    Somma in un FOR

    Cosa sbaglio in questo ciclo?
    codice:
    punteggioTotale = 0
    	for i = 0 to ubound(premio)
    		query = "select * from PREMI where idPremio = "&premio(i)
    		set RS = conn.execute(query)
    		If not RS.eof Then
    			punteggio = RS("punteggio")
    			nomePremio = RS("nomePremio")
    			'response.write nomePremio&"-"&punteggio
    			punteggioTotale = punteggioTotale + punteggio<--linea 14
    		End If
    		RS.close
    		Set RS = nothing
    	next
    ERRORE:
    Errore di run-time di Microsoft VBScript error '800a000d'

    Tipo non corrispondente

    RichiestaPremio.asp, line 14
    tre fiorini!!!

  2. #2
    Utente di HTML.it L'avatar di Corwin
    Registrato dal
    Jan 2002
    Messaggi
    584
    o RS("punteggio") è vuoto oppure non è numerico ma è una stringa.
    I don't wanna have to shout it out / I don't want my hair to fall out
    I don't wanna be filled with doubt / I don't wanna be a good boy scout
    I don't wanna have to learn to count / I don't wanna have the biggest amount
    I don't wanna grow up

  3. #3
    non è mai vuoto (al max è 0 valore di default nel DB) e me lo assicuro col response.write. Se non fosse numerico basterebbe mettere

    punteggioTotale = punteggioTotale + cint(punteggio)??

    ma non funziona neanche cosi
    tre fiorini!!!

  4. #4
    Utente di HTML.it L'avatar di Corwin
    Registrato dal
    Jan 2002
    Messaggi
    584
    Originariamente inviato da ragnetta
    non è mai vuoto (al max è 0 valore di default nel DB) e me lo assicuro col response.write. Se non fosse numerico basterebbe mettere

    punteggioTotale = punteggioTotale + cint(punteggio)??

    ma non funziona neanche cosi
    Da ancora errore "tipo non corrispondente" oppure da un errore quando cerchi di fare cint ?
    I don't wanna have to shout it out / I don't want my hair to fall out
    I don't wanna be filled with doubt / I don't wanna be a good boy scout
    I don't wanna have to learn to count / I don't wanna have the biggest amount
    I don't wanna grow up

  5. #5
    ora funziona:
    ho trasformato
    punteggioTotale = 0
    in
    punteggioTotale = "0"

    e
    punteggioTotale = punteggioTotale + punteggio
    in
    punteggioTotale = Cint(punteggioTotale) + Cint(punteggio)
    tre fiorini!!!

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.