Click to See Complete Forum and Search --> : [RESOLVED] How to add dots to the prices


telmessos
04-27-2007, 10:04 AM
Hi all,

My ASP code gets the prices of my products from an INT field in my database. On the product info display page I want my code to put a dot in every 3 digits from the right side. E.g:

Now it shows like "1223000 GBP"
I want it to show like "1.223.000 GBP"

Any idea ?

Thanks

russell
04-27-2007, 01:10 PM
FormatCurrency (http://www.w3schools.com/vbscript/func_formatcurrency.asp) function should do it...though I've never used it with anything other than us-english settings.

russell
04-27-2007, 01:19 PM
if that doesn't work, this function will

Dim intGBP
intGBP = 1223000

Response.Write formatC(intGBP)

Function formatC(v)
Dim tmp
Dim i
Dim ln

tmp = cstr(v)
ln = Len(tmp) Mod 3

For i = 0 to Len(tmp)
If (i > 0) And (i mod 3 = ln) And (i < len(tmp)) Then
formatC = formatC & "."
End If
formatC = formatC & mid(tmp, i+1, 1)
Next
formatC = formatC & " GBP"
End function

telmessos
04-27-2007, 03:05 PM
hi russell,
on the second code you give, does it matter where I put the function? or can it be called anywhere in the script?
because i could not make any of them work

(sorry it was my fault. it is sorted ;))