Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Percentage Return

Status
Not open for further replies.

terawebwriter

Programmer
Nov 22, 2002
10
US
How would you get a Division to return only 2 numbers. For example, if you want to divide 2 totals and than return only 2 numbers instead of (EX)1.32398795094, how would you do that. This is my code:

<%
Dim T1
T1 = Total1 / Total2
Response.Write (T1)
%>%

Yes, there is a second % sign after the ASP code. Reason I want the number to end up being a % of a whole.
Ex:
Say, 5 departments, each one completed 20%, 30%, 10%, 10%, 30%, something like that.
 
Description
Returns a number rounded to a specified number of decimal places.
Syntax
Round(expression[, numdecimalplaces])
The Round function syntax has these parts:

Part Description
expression Required. Numeric expression being rounded.
numdecimalplaces Optional. Number indicating how many places to the right of the decimal are included in the rounding. If omitted, integers are returned by the Round function.


Remarks
The following example uses the Round function to round a number to two decimal places:
Dim MyVar, pi
pi = 3.14159
MyVar = Round(pi, 2) 'MyVar contains 3.14.


--------------------------------------------------------------------------------
====================================
I love people. They taste just like
chicken!
 
Thank You. It worked great. This is the actual code:

<% Dim T1
T1 = (Total1 / Total2) * 100
T1 = Round(T1, 2)
Response.Write (T1)
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top