Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12

Discussione: (ASP) Arrotondamento

  1. #1

    (ASP) Arrotondamento

    ciao a tutti quelli del Forum
    ho un numero (3315.24) dovrei arrotondarlo alle centinaia (3300) come che posso fare tramite le ASP??
    Ho trovato la funzione Cint ma mi toglie solo i valori dopo la virgola!

    G R A Z I E

  2. #2
    Utente di HTML.it L'avatar di Sypher
    Registrato dal
    Jun 2003
    Messaggi
    1,994

    Re: (ASP) Arrotondamento

    Originariamente inviato da SuperMariano81
    ciao a tutti quelli del Forum
    ho un numero (3315.24) dovrei arrotondarlo alle centinaia (3300) come che posso fare tramite le ASP??
    Ho trovato la funzione Cint ma mi toglie solo i valori dopo la virgola!

    G R A Z I E
    beh per arrotondarlo alle centinaia devi scrivere una semplice funzioncina tu, non credo esista qualche funzione che lo faccia
    La passera non dura perchè Sypher la cattura!

    "No one like us we don't care, we are millwall, super millwall, we are millwall from the DEN"

  3. #3
    Utente di HTML.it L'avatar di Sypher
    Registrato dal
    Jun 2003
    Messaggi
    1,994
    mmm...na cosa del genere:
    codice:
    Private Function arrotonda(num)
        numerointero = FormatNumber(num, 0)
        If (Len(CStr(numerointero))) > 2 Then
            centinaia = Left(numerointero, Len(numerointero) - 2)
            arrotonda = centinaia & "00"
        End If
    End Function
    p.s. ricorda che se usi CInt se il numero è più grande di 35000 più o meno , non ricordo il numero esatto va in errore!
    La passera non dura perchè Sypher la cattura!

    "No one like us we don't care, we are millwall, super millwall, we are millwall from the DEN"

  4. #4
    Ecco un codicino da me fatto (ho preso spunto da quello suggerito da Sypher)

    codice:
    Private Function arrotonda(num)
        num = Replace(num, ".", ",") 
        num = CInt(num)
        If (Len(CStr(num))) >= 4 Then
            fisso = Left$(num, 2)
            centinaia = Right$(num, 2)
            If centinaia > 50 Then
                              fisso = fisso + 1
    
            End If
            arrotonda = fisso & "00"
                                    Else
        If (Len(CStr(num))) = 3 Then
            fisso = Left$(num, 1)
            centinaia = Right$(num, 2)
            If centinaia > 50 Then
                              fisso = fisso + 1
    
            End If
            arrotonda = fisso & "00"
        End If
        End If
    End Function
    Arrotonda numeri di 4 o 3 cifre e con la virgola (o il punto).
    Funziona bene :sexpulp:

    Grazie Sypher per l'idea

  5. #5
    Utente di HTML.it L'avatar di Corwin
    Registrato dal
    Jan 2002
    Messaggi
    584
    x = 3315.24
    x = (Int(x / 100) * 100
    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

  6. #6
    Utente di HTML.it L'avatar di Sypher
    Registrato dal
    Jun 2003
    Messaggi
    1,994
    Originariamente inviato da Corwin
    x = 3315.24
    x = (Int(x / 100) * 100
    mmm...interessante!
    ma c'è un errorino!
    codice:
    x = 3315.24
    x = CInt(x / 100) * 100
    :zamm:
    La passera non dura perchè Sypher la cattura!

    "No one like us we don't care, we are millwall, super millwall, we are millwall from the DEN"

  7. #7
    Utente di HTML.it L'avatar di Corwin
    Registrato dal
    Jan 2002
    Messaggi
    584
    Originariamente inviato da Sypher
    mmm...interessante!
    ma c'è un errorino!
    codice:
    x = 3315.24
    x = CInt(x / 100) * 100
    :zamm:
    Ah si ? E perchè sarebbe un errore ? :quipy:
    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

  8. #8
    Utente di HTML.it L'avatar di Sypher
    Registrato dal
    Jun 2003
    Messaggi
    1,994
    Originariamente inviato da Corwin
    Ah si ? E perchè sarebbe un errore ? :quipy:
    quello è quello corretto...tu al posto della C avevi messo la parentesi!

    Originariamente inviato da Corwin
    codice:
    x = 3315.24
    x = (Int(x / 100) * 100
    La passera non dura perchè Sypher la cattura!

    "No one like us we don't care, we are millwall, super millwall, we are millwall from the DEN"

  9. #9
    Utente di HTML.it L'avatar di Corwin
    Registrato dal
    Jan 2002
    Messaggi
    584
    Ok, c'era una parentesi in più, ma la funzione Int esiste e funziona.
    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

  10. #10
    Utente di HTML.it L'avatar di Sypher
    Registrato dal
    Jun 2003
    Messaggi
    1,994
    Originariamente inviato da Corwin
    Ok, c'era una parentesi in più, ma la funzione Int esiste e funziona.
    è vero anche questo! però l'errorino c'era! :zamm:
    La passera non dura perchè Sypher la cattura!

    "No one like us we don't care, we are millwall, super millwall, we are millwall from the DEN"

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.