Office中国论坛/Access中国论坛

标题: 大家看看我写的模块,四舍五入,小数取整 [打印本页]

作者: krts    时间: 2003-6-7 00:46
标题: 大家看看我写的模块,四舍五入,小数取整
Function Roundx(Fnumber As Double, Inumber As Integer) As Double

''/*/四舍五入函数(正数舍小数,负数舍整数部份) _
eg: roundx(12.235,2)=12.24;roundx(1234.12,-2)=1200
Dim Temproundx As Double
Temproundx = Fnumber * 10 ^ Inumber - Int(Fnumber * 10 ^ Inumber)
If Temproundx >= 0.49999 Then
Temproundx = Int(Fnumber * 10 ^ Inumber + 1) / 10 ^ Inumber
Else
Temproundx = Int(Fnumber * 10 ^ Inumber) / 10 ^ Inumber
End If
Roundx = Temproundx
Temproundx = 0
End Function




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