Office中国论坛/Access中国论坛

标题: 求助:为何四舍五入函数不起作用 [打印本页]

作者: zhongbaba    时间: 2006-6-20 21:31
标题: 求助:为何四舍五入函数不起作用
求助:为何四舍五入函数不起作用?

使用以下代码:

Public Function RoundToLarger(dblInput As Double, intDecimals As Integer) As Double
   
    'Implements a variant of the Round() function, that rounds-to-larger
    'rather than rounds-to-even:
        
    Dim strFormatString As String 'Format string
   
    'If input is zero, just return zero. Else format as appropriate:
    If dblInput <> 0 Then
        strFormatString = "#." & String(intDecimals, "#")
        RoundToLarger = Format(dblInput, strFormatString)
    Else
        RoundToLarger = 0
    End If
   
End Function

却不能将56.54X5430四舍五入,得数为307012.22,而不是307012.20?

请各位帮忙解决,谢谢!




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3