Friday, January 13, 2006

ceiling and floor implementation for vb6

Public Function Ceiling(ByVal X As Currency, Optional ByVal Factor As Currency = 1) As Currency
' X is the value you want to round
' is the multiple to which you want to round
Ceiling = (Int(X / Factor) - (X / Factor - Int(X / Factor) > 0)) * Factor
End Function

Public Function Floor(ByVal X As Currency, Optional ByVal Factor As Currency = 1) As Currency
' X is the value you want to round
' is the multiple to which you want to round
Floor = Int(X / Factor) * Factor
End Function

0 Comments:

Post a Comment

<< Home