|
-
Oct 3rd, 2000, 12:34 PM
#1
Thread Starter
Hyperactive Member
I am needing to take the average of 5 numbers that will usually be between 800 and 1200 each. The numbers I am returning need to be whole numbers (906, not 906.42634...). Thanks for any help.
If you think education is expensive, try ignorance.
-
Oct 3rd, 2000, 01:44 PM
#2
How about using Vb6's Round function?
Code:
MsgBox Round(906.42634) 'returns 906
If you do not have Vb6, you can use this code:
Code:
Function Round(nValue As Double, nDigits As _
Integer) As Double
Round = Int(nValue * (10 ^ nDigits) + _
0.5) / (10 ^ nDigits)
End Function
Usage:
MsgBox Round(906.42634, 0) 'returns 906
MsgBox Round(906.42634, 2) 'returns 906.43
-
Oct 3rd, 2000, 02:06 PM
#3
Thread Starter
Hyperactive Member
In VB I'm sure that would work. I just don't know how to make that work in ASP. I tried using the Round function as follows but it didn't work.
Code:
round(intAht_avg = (int(aht1) + int(aht2) + int(aht3) + int(aht4) + int(aht5) + int(aht6) + int(aht7))/5)
Thanks for any help
If you think education is expensive, try ignorance.
-
Oct 3rd, 2000, 03:57 PM
#4
Frenzied Member
The round() function is available in vbscript and works just like Matthew described...
Code:
intAht_avg = round((round(aht1) + round(aht2) + round(aht3) + round(aht4) + round(aht5) + round(aht6) + round(aht7))/7))
'If you need an average, you will need to divide by 7 not 5 here)
'Or for a more acurate (but not totally accurate) average:
intAht_avg = round((aht1 + aht2 + aht3 + aht4 + aht5 + aht6 + aht7)/7)
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Oct 3rd, 2000, 04:29 PM
#5
Thread Starter
Hyperactive Member
I found that using Cint did exactly what I was looking for. Thank you though.
The people I would be doing these for are working 5 out of the 7 days, so dividing by 5 was the correct number. the others default to 0
If you think education is expensive, try ignorance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|