[分享]真正的四舍五入的函数-赖观配
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> Access数据库-模块/函数/VBA


[分享]真正的四舍五入的函数

发表时间:2007/10/22 12:54:50 评论(4) 浏览(17453)  评论 | 加入收藏 | 复制
   
摘 要:[分享]真正的四舍五入的函数
正 文:
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
=====================================
? round(2.385, 2)
2.38
? roundtolarger(2.385, 2)
2.39

转自: www.tek-tips.com/faqs.cfm?spid=705&rat1=10&sfid=3734
本站来源: ACCESS中国 zhuyiwen

Access软件网交流QQ群(群号:198465573)
 
 相关文章
Round函数四舍五入不正确,怎么办?   【Dave Mc Donald   2004/11/10】
为什么Round函数没有正确地四舍五入  【andymark  2008/1/9】
《关于“四舍五入”总结》  【UMVSoft整理  2009/5/14】
小写金额转换为大写金额函数(含主动四舍五入)  【wsl  2012/2/12】
Access style--加减乘除计算的示例,相加结果为四舍五入...  【麥田  2012/12/9】
【Round】函数四舍五入的规则  【落尘_小新  2012/3/29】
四舍五入函数自定义又一例  【不详  2012/3/30】
常见问答
技术分类
相关资源
文章搜索
关于作者

赖观配

文章分类

文章存档

友情链接