设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 7887|回复: 50
打印 上一主题 下一主题

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

[复制链接]

点击这里给我发消息

跳转到指定楼层
1#
发表于 2003-9-10 18:40:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. Public Function RoundToLarger(dblInput As Double, intDecimals As Integer) As Double
  2.    
  3.     'Implements a variant of the Round() function, that rounds-to-larger
  4.     'rather than rounds-to-even:
  5.         
  6.     Dim strFormatString As String 'Format string
  7.    
  8.     'If input is zero, just return zero. Else format as appropriate:
  9.     If dblInput <> 0 Then
  10.         strFormatString = "#." & String(intDecimals, "#")
  11.         RoundToLarger = Format(dblInput, strFormatString)
  12.     Else
  13.         RoundToLarger = 0
  14.     End If
  15.    
  16. End Function
复制代码
转自: http://www.tek-tips.com/faqs.cfm?spid=705&amp;rat1=10&amp;sfid=3734
  1. ? Round(2.385, 2)
  2. 2.38
  3. ? RoundToLarger(2.385, 2)
  4. 2.39
复制代码

本帖被以下淘专辑推荐:

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖2 订阅订阅
2#
发表于 2003-11-17 08:28:00 | 只看该作者
但为何1500*4123却得数带小数了,不明
3#
发表于 2003-11-17 08:29:00 | 只看该作者
还有1.255*3得数是3.76而不是3.77,更不明了
4#
发表于 2007-6-30 04:33:00 | 只看该作者
HI
5#
发表于 2007-6-30 16:57:00 | 只看该作者
謝謝分享
6#
发表于 2007-7-2 17:54:00 | 只看该作者
lk
7#
发表于 2007-7-3 17:56:00 | 只看该作者
不可不看!
8#
发表于 2007-7-22 00:22:00 | 只看该作者
不是吧,这么麻烦!!!!!!!![em18]
9#
发表于 2007-7-24 19:36:00 | 只看该作者
正需要这个,看看!!!!!11
10#
发表于 2007-7-24 20:03:00 | 只看该作者
看看
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-23 23:01 , Processed in 0.208011 second(s), 35 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表