ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old June 23rd, 2003, 09:31 PM
niroff niroff is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 7 niroff User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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>

Reply With Quote
  #2  
Old June 23rd, 2003, 09:53 PM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Add the number of decimal places you wish to round to the end of the Round, as follows:

Quote:
document.write(Round(i,#))


Where # is the number of places to round to.
__________________
How can I soar like an eagle when
I'm flying with turkey's?

Reply With Quote
  #3  
Old June 23rd, 2003, 10:08 PM
niroff niroff is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 7 niroff User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
it cant work..

Reply With Quote
  #4  
Old June 23rd, 2003, 10:12 PM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Try changing document.write to response.write

I believe document.write is a javascript function not a vbscript function.

Reply With Quote
  #5  
Old June 23rd, 2003, 10:16 PM
niroff niroff is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 7 niroff User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
<%

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)))

Reply With Quote
  #6  
Old June 23rd, 2003, 10:20 PM
mohecan mohecan is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 212 mohecan User rank is Private First Class (20 - 50 Reputation Level)mohecan User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
result= Round(CLng(r3)*CLng(I)/(CLng(r2)+CLng(r3)),2)

Should work.

Reply With Quote
  #7  
Old June 24th, 2003, 12:35 AM
niroff niroff is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 7 niroff User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
it works thanks!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Rounding of number to 2 decimal places or more..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway