📜  vba 整数 - VBA 代码示例

📅  最后修改于: 2022-03-11 14:51:55.798000             🧑  作者: Mango

代码示例1
Function RoundTo(pNumber As Long, pFactor As Long)
    RoundTo = Round(pNumber / pFactor) * pFactor 
End Function
' ---------------------------------------------------------------
Sub TestMe()
    Debug.Print RoundTo(2543, 10)                ' => 2540
    Debug.Print RoundTo(2546, 10)                ' => 2550
    Debug.Print Application.RoundUp(10.1, 0)     ' => 10
    Debug.Print Application.RoundUp(10.6, 0)     ' => 11
    Debug.Print Application.RoundDown(10.6, 0)     ' => 10
End Sub