Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Round in asp .net

  1. #1

    Round in asp .net

    Ho questa funzione:

    Function FormattaPrezzoPerDB(ByVal FormattaPrezzoPerDB_StringaPrezzo)

    Dim FormattaPrezzoPerDB_StringaIntero, FormattaPrezzoPerDB_StringaDecimale

    If InStr(FormattaPrezzoPerDB_StringaPrezzo, ",") > 0 Then
    FormattaPrezzoPerDB_StringaDecimale = Mid(FormattaPrezzoPerDB_StringaPrezzo, InStr(FormattaPrezzoPerDB_StringaPrezzo, ",") + 1)
    If Len(FormattaPrezzoPerDB_StringaDecimale) > 2 Then
    FormattaPrezzoPerDB_StringaDecimale = CStr(Round (CLng(FormattaPrezzoPerDB_StringaDecimale) / (10 ^ (Len(FormattaPrezzoPerDB_StringaDecimale) - 2))))
    Do While Len(FormattaPrezzoPerDB_StringaDecimale) < 2
    FormattaPrezzoPerDB_StringaDecimale = "0" & FormattaPrezzoPerDB_StringaDecimale
    Loop
    Else
    Do While Len(FormattaPrezzoPerDB_StringaDecimale) < 2
    FormattaPrezzoPerDB_StringaDecimale = FormattaPrezzoPerDB_StringaDecimale & "0"
    Loop
    End If
    FormattaPrezzoPerDB_StringaIntero = Mid(FormattaPrezzoPerDB_StringaPrezzo, 1, InStr(FormattaPrezzoPerDB_StringaPrezzo, ",") - 1)
    Else
    FormattaPrezzoPerDB_StringaDecimale = "00"
    FormattaPrezzoPerDB_StringaIntero = FormattaPrezzoPerDB_StringaPrezzo
    End If

    FormattaPrezzoPerDB = FormattaPrezzoPerDB_StringaIntero & "" & FormattaPrezzoPerDB_StringaDecimale
    End Function

    in asp funziona ma in asp .net mi da errore su Round, dice "Nome non dichiarato", ma non è una funzione??
    AIUTOOOOOOOOOOOOOOO!

  2. #2
    L'errore è dovuto al fatto che in asp .net Round è un metodo della Classe Math. Per utilizzarlo quindi dovrai eseguire la chiamata di quel metodo.

    Ad esempio:

    codice:
    Dim k As Double = 12.324
    Math.Round(k, 1) 'Restituisce 12.3
    La documentazione al riguardo la trovi al seguente link:
    http://msdn.microsoft.com/library/de...roundtopic.asp
    Nicola Baldi <% Naighes %>
    Il mio blog!

    "Non hai veramente capito qualcosa fino a quando non sei in grado di spiegarlo a tua nonna."

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.