Public Function RoundToPrecision( _
ByVal vNumber As Variant _
, Optional ByVal vPrecision As Variant _
) As Variant RoundToPrecision(45.3) = 45
RoundToPrecision(45.5) = 46 ' #2
RoundToPrecision(45.7) = 46
RoundToPrecision(-45.7) = -46
RoundToPrecision(-45.5) = -45 ' #5
RoundToPrecision(-45.3) = -45
RoundToPrecision(-45.37, .1) = -45.4
RoundToPrecision(-12.3456, .01) = -12.35See also: RoundToPrecisionVerify Subroutine
RoundToDigits Function
Round Function (Visual Basic)
Ceiling Function
Floor Function
NextNumber Function
PreviousNumber FunctionvNumber: The number that is rounded either up or down to the nearest vPrecision. Function returns Null if vNumber is Null or cannot be fixed up to a number. vPrecision: The nearest number to which vNumber is rounded. vPrecision defaults to 1 (zero) if it is missing or Null or cannot be fixed up to a String. With a precision of 1 (one), vNumber will be rounded to the nearest integer; with a precision of .1, vNumber will be rounded to the nearest tenth, etc.
Definition:
Floor(vNumber / vPrecision + .5) * vPrecisionv1.3 BugFix: This function was returning incorrect results in prior versions of Entisoft Tools. Both the Function and its Definition have been corrected.
Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.