Skinny site

... un modo di esprimersi

  • Aumenta dimensione caratteri
  • Dimensione caratteri predefinita
  • Diminuisci dimensione caratteri
Home Code Snippets ASP Funzione ASP che trasforma un numero nel formato (#.###.###,##)

Funzione ASP che trasforma un numero nel formato (#.###.###,##)

E-mail Stampa PDF
Valutazione attuale: / 0
ScarsoOttimo 
Questa piccola funzione permette di cambiare il formato di un numero passato come parametro, inserendo il separatore delle migliaia e due cifre decimale dopo la virgola.
Function FormatItNumner(ByVal Amount)
Dim myInt, myDec, myNewInt, i, lenInt, myStr, myPos

if not isnull(Amount) then
Amount = CStr(Amount)
if Amount <> "0" and Amount <>"" then
myInt = Left(Amount, Len(Amount) - 2)
myDec = Right(Amount, 2)
lenInt = Len(myInt)
i = 0
myPos = lenInt
Do Until i = lenInt
If (i Mod 3) = 0 Then
If i < 3 Then
myStr = Mid(myInt, myPos, 1) & myStr
Else
myStr = Mid(myInt, myPos, 1) & "." & myStr
End If
Else
myStr = Mid(myInt, myPos, 1) & myStr
End If
myPos = myPos - 1
i = i + 1
Loop
end if
end if
if myDec <> "" then
FormatItNumner = myStr & "," & myDec
else
FormatItNumner = myStr
end if
End Function
Ultimo aggiornamento Domenica 10 Agosto 2008 13:25  

Google Analytics Tracking Module