Here's a RoundUp function I have written that hopefully might help:
Function jpsvbRoundUp(pvarNum, pvarDecimals)
' Purpose: Round up.
' Remarks: Usually makes numbers farther from 0 even if the important
digit is less than 5.
' Examples:
' jpsvbRoundUp(3.451, 2) -> 3.46
' jpsvbRoundUp(-3.451, 2) -> -3.46
' Dim var.
Dim varNum
Dim varDecimals
Dim varBigValue
' Quick exit if either item not numeric.
If (Not IsNumeric(pvarNum)) Or (Not IsNumeric(pvarDecimals)) Then
jpsvbRoundUp = 0
Exit Function
End If
' Set var.
varNum = pvarNum
' Round decimals to an integer in case not one already.
' (Note that VBScript's Round() also rounds its decimals parameter.)
' (If used CInt() instead of Round() it could have had a rounding error
' if important digit were 5.)
varDecimals = Round(pvarDecimals, 0)
' Convert 3.456 to 2 decimal places up to be 345.6
varBigValue = varNum * 10 ^ varDecimals
If varBigValue = Fix(varBigValue) Then
jpsvbRoundUp = varBigValue / 10 ^ varDecimals
Else
' Add 1 to the above 345.6 to get 346.6.
' (But if the orig number is neg., then subtract 1 instead.)
' Then chop off the fractional .6 to leave 346.
' Then convert 346 back down to 3.46.
If varNum >= 0 Then
jpsvbRoundUp = Fix(varBigValue + 1) / 10 ^ varDecimals
Else
jpsvbRoundUp = Fix(varBigValue - 1) / 10 ^ varDecimals
End If
End If
End Function
Best regards,
J. Paul Schmidt, Freelance Web and Database Developer
http://www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
<<
I have the following equation.
<% varWT = Round(CInt((rsFreePack.Fields.Item("Weight").Value)) +
CInt(Session("w"))) %>
Assume....
Round(CInt((rsFreePack.Fields.Item("Weight").Value)) = .12
CInt(Session("w")) = 30
How can I get it to always ROUND up to 31 ...?
thanks