设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

[与其它组件] 请教高手:打印人民币中文大写(多谢指点!)

[复制链接]
跳转到指定楼层
1#
发表于 2004-3-2 18:44:00 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
[B]各位高手,各位大哥:[/B]

       老板要求利用Access中的报表打印功能打印收费单据。但是,没有象Excel那样可以装一个转换函数转换成中文大写呀。急死人了!!   特向各位求救。[B]万分感谢!!![/B]
Tony
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
6#
发表于 2008-5-6 15:37:55 | 只看该作者
感谢!试试看。[:50]
5#
 楼主| 发表于 2004-3-4 05:40:00 | 只看该作者
问题解决了!!感谢指点!

       感谢斑竹以及风大哥的指点!非常好用。多谢多谢!!

Tony
4#
发表于 2004-3-3 08:05:00 | 只看该作者
你把他以下的东西拷到一个模块里,然后在用到的地方这样用:getdxje(你要转换的金额)

Private Function Num2Char(ByVal I As Integer) As String
If I >= 0 And I <= 9 Then
Num2Char = Mid$("零壹贰叁肆伍陆柒捌玖", I + 1, 1)
Else
Num2Char = ""
End If
End Function
Private Function Num2RMB(ByVal sFourBitString As String, Optional _
ByVal sUnit As String = "元", Optional ByVal bMustHeader As _
Boolean = False) As String
'----------------------------------------------------------------------
Dim vNum, I, RX, BR, hdr
'------------------------------------------------------------------
BR = "仟佰拾元"
'------------------------------------------------------------------
vNum = Trim(Str(Val(sFourBitString))) ' 最多四位
'------------------------------------------------------------------
If (Len(vNum) < 4 And Len(vNum) > 0) And bMustHeader Then hdr = "零" _
Else hdr = ""
RX = ""
Do While Len(vNum) > 0
I = Right(vNum, 1)
If I > 0 Then
RX = Num2Char(I) + Right(BR, 1) + RX
Else
If Left(RX, 1) <> "零" Then RX = "零" + RX
End If
vNum = Left(vNum, Len(vNum) - 1)
BR = Left(BR, Len(BR) - 1)
Loop
RX = Left(RX, Len(RX) - 1)
If Right(RX, 1) = "零" Then ' 去除多余的零
RX = Left(RX, Len(RX) - 1)
End If
If Len(RX) > 0 Then
Num2RMB = hdr + RX + sUnit
Else
Num2RMB = RX + IIf(sUnit = "元", "元", "")
End If
End Function
Function GetDXJE(ByVal Num As Currency) As String ' 得到大写金额
'----------------------------------------------------------------------
Dim vNum, vDec, ret, qb

'------------------------------------------------------------------
vNum = Right(Format(Int(Num), "000000000000"), 12) ' 取十二位整数
vDec = Right(Format(Int(Num * 100 + 0.5), "00"), 2) ' 取小数点后两位并自动四舍五入
'------------------------------------------------------------------
ret = Num2RMB(Left(vNum, 4), "亿", False)
If Len(ret) = 0 Then
ret = Num2RMB(Mid(vNum, 5, 4), "万", False)
Else
ret = ret + Num2RMB(Mid(vNum, 5, 4), "万", True)
End If
If Len(ret) = 0 Then
ret = Num2RMB(Right(vNum, 4), "元", False)
Else
ret = ret + Num2RMB(Right(vNum, 4), "元", True)
End If
'------------------------------------------------------------------
If ret = "元" Then
  ret = ""
  qb = ""
  Else
  qb = "xx"
End If
'------------------------------------------------------------------

If vDec = "00" And qb <> "" Then '1.00
    ret = ret + "整"
End If
If vDec = "00" And qb = "" Then '0.00
     ret = "(无金额)"
   
End If
   
If Left(vDec, 1) <> "0" And Right(vDec, 1) = 0 And qb <> "" Then '1.20
     ret = ret + Num2Char(Left(vDec, 1)) + "角整"
End If
If Left(vDec, 1) = "0" And Right(vDec, 1) <> 0 And qb <> "" Then '1.03
     ret = ret + "零" + Num2Char(Right(vDec, 1)) + "分"
End If
If Left(vDec, 1) <> "0" And Right(vDec, 1) <> 0 And qb <> "" Then '1.23
     ret = ret + Num2Char(Left(vDec, 1)) + "角" + Num2Char(Right(vDec, 1)) + "分"
End If
If Left(vDec, 1) <> "0" And Right(vDec, 1) = 0 And qb = "" Then '0.20
     ret = Num2Char(Left(vDec, 1)) + "角整"
End If
If Left(vDec, 1) = "0" And Right(vDec, 1) <> 0 And qb = "" Then '0.03
     ret = Num2Char(Right(vDec, 1)) + "分"
End If
If Left(vDec, 1) <> "0" And Right(vDec, 1) <> 0 And qb = "" Then '0.23
     ret = Num2Char(Left(vDec, 1)) + "角" + Num2Char(Right(vDec, 1)) + "分"
End If
   
GetDXJE = ret
'----------------------------------------------------------------------
End Function
3#
 楼主| 发表于 2004-3-2 22:34:00 | 只看该作者
风大哥:
       非常感谢您的指点!  
       我对编程不太懂,我怎样在我的报表或者查询里调用你的程序呢?您能不能解释详细一点。非常感谢!

Tony

2#
发表于 2004-3-2 19:17:00 | 只看该作者
http://www.office-cn.net/bbs/dispbbs.asp?boardID=2&ID=14123
这里面有一个的。(来自这个网站)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-15 09:22 , Processed in 0.094773 second(s), 30 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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