如何把小写金额转换成大写的金额?

musandy 2004-08-09 12:05:42
例如输入:1234.56元时,可以自动转换为壹仟贰佰叁拾肆元伍角陆分
...全文
247 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
rtur 2004-08-09
  • 打赏
  • 举报
回复
to musandy(小倩)
晕~~.
我说的csdn就是本站呀.不是MSDN哟.
我提供的链接里面,就有的啦,就是一个函数,调用它就成.
zhuiguo 2004-08-09
  • 打赏
  • 举报
回复
自己用函数来取一下!
就像三楼那样!
musandy 2004-08-09
  • 打赏
  • 举报
回复
rtur(生活没有 Ctrl-Z) :
你好,我也想安装csdn但,我的VB安装盘里没有,不知在哪里可以下载?
guxizhw 2004-08-09
  • 打赏
  • 举报
回复
给你一个


Public Function ToChineseMoney(ByVal dbMoney As Double) As String

Dim strChineseMoney As String

Dim intMoneyPos As Integer

Dim strMoney As String

Dim j As Integer

Dim k As Integer

Dim varN1 As Variant

Dim varN2 As Variant

Dim varN3 As Variant

varN1 = Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖")

varN2 = Array("", "拾", "佰", "仟")

varN3 = Array("元", "万", "亿")

strMoney = Format(CStr(Abs(dbMoney)), "0.00")

intMoneyPos = Len(strMoney)

If CInt(Mid(strMoney, intMoneyPos, 1)) <> 0 Then

strChineseMoney = varN1(CInt(Mid(strMoney, intMoneyPos, 1))) & "分"

End If

intMoneyPos = intMoneyPos - 1

If CInt(Mid(strMoney, intMoneyPos, 1)) <> 0 Then

strChineseMoney = varN1(CInt(Mid(strMoney, intMoneyPos, 1))) & "角" & strChineseMoney

End If

If Round(Abs(dbMoney)) = 0 Then

ToChineseMoney = strChineseMoney

If dbMoney < 0 Then strChineseMoney = "负" & strChineseMoney

Exit Function

End If

intMoneyPos = intMoneyPos - 2 ''移动到个位

j = 0

k = 0

While intMoneyPos > 0

If j Mod 4 = 0 Then

strChineseMoney = varN3(k) & strChineseMoney

k = k + 1

If k > 2 Then

k = 1

End If

j = 0

End If

If Mid(strMoney, intMoneyPos, 1) <> 0 Then

strChineseMoney = varN2(j) & strChineseMoney

End If

strChineseMoney = varN1(CInt(Mid(strMoney, intMoneyPos, 1))) & strChineseMoney

j = j + 1

intMoneyPos = intMoneyPos - 1

Wend

While InStr(1, strChineseMoney, "零零") > 0

strChineseMoney = Replace(strChineseMoney, "零零", "零")

Wend

strChineseMoney = Replace(strChineseMoney, "零亿", "亿零")

While InStr(1, strChineseMoney, "零零") > 0

strChineseMoney = Replace(strChineseMoney, "零零", "零")

Wend

strChineseMoney = Replace(strChineseMoney, "零万", "万零")

While InStr(1, strChineseMoney, "零零") > 0

strChineseMoney = Replace(strChineseMoney, "零零", "零")

Wend

strChineseMoney = Replace(strChineseMoney, "零元", "元")

strChineseMoney = Replace(strChineseMoney, "亿万", "亿")

strChineseMoney = Replace(strChineseMoney, "亿万", "亿")

While InStr(1, strChineseMoney, "零壹拾") > 0

strChineseMoney = Replace(strChineseMoney, "零壹拾", "零拾")

Wend

'If Left(strChineseMoney, 2) = "壹拾" Then
'
' strChineseMoney = Right(strChineseMoney, Len(strChineseMoney) - 1)
'
'End If

If dbMoney < 0 Then

strChineseMoney = "负" & strChineseMoney

End If

ToChineseMoney = strChineseMoney

End Function

rtur 2004-08-09
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/2810/2810169.xml?temp=.4786798
rtur 2004-08-09
  • 打赏
  • 举报
回复
csdn里搜索一下,多的是。
musandy 2004-08-09
  • 打赏
  • 举报
回复
不好意思,一时看错了,谢谢大家。
guxizhw 2004-08-09
  • 打赏
  • 举报
回复
我郁闷……提供了函数还要找msdn,当偶不存在:(

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧