PDA

View Full Version : Decimal fucntion?!?!


Morgoth
12-05-2002, 09:25 PM
Now, is there a function that will allow me to place in a number and it will change the decimal place to whatever number I gave it?

Example:

Function(1234.5678, 2)
Response = 1234.56
Is there a function for that?

Morgoth
12-05-2002, 10:07 PM
Format(1234.5678, "##.#0")

Format is not a function in ASP. I have learned that awhile ago when I used:
FormatDateTime()

And the problem with this is that I can't get my information without format... lol, little joke there :) kekekekeke

Roy Sinclair
12-05-2002, 11:15 PM
Use the FormatNumber function.

Start here (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtoriVBScript.asp) and drill down to the reference for functions.

whammy
12-06-2002, 12:48 AM
Do you want to round to a certain number of decimal places?

<% = Round(1234.5678,2) %>

<% = FormatCurrency(1234.5678) %>

Morgoth
12-06-2002, 03:52 AM
I guess either one of those will do it whammy.

But common! no format()... That makes me mad...

I also wrote this thing up cause I was impationt and I couldn't wait...


Function Format2(strTemp, Digits)

Dim I
Dim strNew

For I = 1 To Len(strTemp)

If Mid(strTemp, I, 1) = "." Then
strNew = Left(strTemp, I + Digits)

If Mid(strTemp, I + Digits + 1, 1) > 4 Then
strNew = strNew + 10 ^ -Digits
End If

Exit For
End If

Next

Format2 = strNew

End Function

Mhtml
12-08-2002, 04:59 AM
Just thought I'd tack this on to the end of the thread for peeps who browse this, it is a list of formatting functions...May prove useful for some.


FormatCurrency(Expression[,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])

FormatDateTime(Date[, NamedFormat])

FormatNumber(Expression [,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])

FormatPercent(Expression[,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])

Morgoth
12-08-2002, 05:19 AM
When I checked my work, I noticed that the "<% = FormatCurrency(1234.5678) %>" added a $ sign to it automatically, so I removed the one I put in manually for the Canadian and American currency, but I had to use "<% = FormatCurrency(1234.5678) %>" for the British Pounds and Japanese Yen. ;)