|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Rounding of number to 2 decimal places or more..
Hi there.. how do i round off a number to 2 decimal places?
This code taken from www.w3schools.com only round the number to a whole number. <html> <body> <script type="text/vbscript"> i = 48.66776677 j = 48.999 document.write(Round(i)) document.write("<br />") document.write(Round(j)) </script> </body> </html> |
|
#2
|
|||
|
|||
|
Add the number of decimal places you wish to round to the end of the Round, as follows:
Quote:
Where # is the number of places to round to.
__________________
How can I soar like an eagle when I'm flying with turkey's? |
|
#3
|
|||
|
|||
|
it cant work..
|
|
#4
|
|||
|
|||
|
Try changing document.write to response.write
I believe document.write is a javascript function not a vbscript function. |
|
#5
|
|||
|
|||
|
<%
r1=Trim(request.form("r1")) r2=Trim(request.form("r2")) r3=Trim(request.form("r3")) I=Trim(request.form("I")) urans=Trim(request.form("Answer1")) result= Round(CLng(r3)*CLng(I)/(CLng(r2)+CLng(r3))) if (CStr(result) = CStr(urans)) then response.write " the right value is " & result & " ,so you are right" elseif (CStr(result) <> CStr(urans)) then response.write " the right value is " & result & " ,so you are wrong" End if %> this is my code.. how do i change this line to make it 2 decimal places.. so far it rounds off to a whole number result= Round(CLng(r3)*CLng(I)/(CLng(r2)+CLng(r3))) |
|
#6
|
|||
|
|||
|
result= Round(CLng(r3)*CLng(I)/(CLng(r2)+CLng(r3)),2)
Should work. |
|
#7
|
|||
|
|||
|
it works thanks!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Rounding of number to 2 decimal places or more.. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|