标题: 海狸先生 我用你发表的 四舍五入 函数 好像有点问题 [打印本页] 作者: cjls2000 时间: 2005-11-21 17:58 标题: 海狸先生 我用你发表的 四舍五入 函数 好像有点问题 Public Function MyRound(dblInput As Variant, Optional intDecimals As Integer) As Double
Dim strFormatString As String '格式化字符串
If IsNull(dblInput) Then MyRound = 0: Exit Function
If dblInput <> 0 Then
If IsNull(intDecimals) Or intdeximals = 0 Then
MyRound = Val(Format(dblInput, "#"))
Else
strFormatString = "#." & String(Nz(intDecimals), "#")
MyRound = Val(Format(dblInput, strFormatString))
End If
Else
MyRound = 0
End If
End Function
MyRound(0.00555, 3) =0 ???[em06][em06]作者: cjls2000 时间: 2005-12-1 23:21
??没有知道??作者: 海狸先生 时间: 2005-12-2 03:08
Public Function MyRound(dblInput As Variant, Optional intDecimals As Integer) As Double
Dim strFormatString As String '格式化字符串
If IsNull(dblInput) Then MyRound = 0: Exit Function
If dblInput <> 0 Then
If IsNull(intDecimals) Or intDecimals = 0 Then
MyRound = Val(Format(dblInput, "#"))
Else
strFormatString = "#." & String(Nz(intDecimals), "#")
MyRound = Val(Format(dblInput, strFormatString))
End If
Else
MyRound = 0
End If
End Function