在Excel中有自带的Ceiling函数可实现向上取整,但Access,没有,需要自己写一下
以下有2个函数的写法,可参考:
Public Function Ceiling(ByVal X As Double, Optional ByVal Factor As Double = 1) As Double
' X is the value you want to round
' Factor is the optional multiple to which you want to round, defaulting to 1 (默认值为0)
Ceiling = (Int(X / Factor) - (X / Factor - Int(X / Factor) > 0)) * Factor
End Function
Public Function Ceiling(RoundValue As Currency) As Currency
Dim TheValue As Currency
TheValue = RoundValue
Select Case TheValue - Int(TheValue)
Case Is <= 0.25
Ceiling = Int(TheValue)
Case Is >= 0.5
Ceiling = Int(TheValue) + 1
Case Is >= 0.26
Ceiling = Int(TheValue) + 0.5
End Select
End Function