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
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