我想得到的为伍百肆拾三元柒毛八分哦
15 个解决方案
#1
Public Function dfTransToBig(ByVal curMoney As Variant) As String
On Error GoTo ErrTrap
If Not IsNumeric(curMoney) Then
Exit Function
End If
dfTransToBig = ""
Dim strMoney As String
Dim strInt As String
Dim strDec As String
Dim strTemp As String
strMoney = Format(Str(curMoney), "#.00")
strInt = Left(strMoney, Len(strMoney) - 3)
strInt = String(12 - Len(strInt), "0") & Trim(strInt)
strDec = Right(strMoney, 2)
strTemp = dfGroupToBig(Mid(strInt, 1, 4))
If strTemp <> "" Then
dfTransToBig = dfTransToBig & strTemp & "亿"
End If
strTemp = dfGroupToBig(Mid(strInt, 5, 4))
If strTemp <> "" Then
dfTransToBig = dfTransToBig & strTemp & "万"
End If
strTemp = dfGroupToBig(Mid(strInt, 9, 4))
If strTemp <> "" Then
dfTransToBig = dfTransToBig & strTemp
End If
dfTransToBig = dfTransToBig & "圆"
If strDec = "00" Then
dfTransToBig = dfTransToBig & "整"
Else
If Left(strDec, 1) = "0" Then
dfTransToBig = dfTransToBig & dfNumberToBig(Right(strDec, 1)) & "分"
Else
If Right(strDec, 1) = "0" Then
dfTransToBig = dfTransToBig & dfNumberToBig(Left(strDec, 1)) & "角"
Else
dfTransToBig = dfTransToBig & dfNumberToBig(Left(strDec, 1)) & "角" & dfNumberToBig(Right(strDec, 1)) & "分"
End If
End If
End If
Exit Function
ErrTrap:
On Error GoTo 0
End Function
On Error GoTo ErrTrap
If Not IsNumeric(curMoney) Then
Exit Function
End If
dfTransToBig = ""
Dim strMoney As String
Dim strInt As String
Dim strDec As String
Dim strTemp As String
strMoney = Format(Str(curMoney), "#.00")
strInt = Left(strMoney, Len(strMoney) - 3)
strInt = String(12 - Len(strInt), "0") & Trim(strInt)
strDec = Right(strMoney, 2)
strTemp = dfGroupToBig(Mid(strInt, 1, 4))
If strTemp <> "" Then
dfTransToBig = dfTransToBig & strTemp & "亿"
End If
strTemp = dfGroupToBig(Mid(strInt, 5, 4))
If strTemp <> "" Then
dfTransToBig = dfTransToBig & strTemp & "万"
End If
strTemp = dfGroupToBig(Mid(strInt, 9, 4))
If strTemp <> "" Then
dfTransToBig = dfTransToBig & strTemp
End If
dfTransToBig = dfTransToBig & "圆"
If strDec = "00" Then
dfTransToBig = dfTransToBig & "整"
Else
If Left(strDec, 1) = "0" Then
dfTransToBig = dfTransToBig & dfNumberToBig(Right(strDec, 1)) & "分"
Else
If Right(strDec, 1) = "0" Then
dfTransToBig = dfTransToBig & dfNumberToBig(Left(strDec, 1)) & "角"
Else
dfTransToBig = dfTransToBig & dfNumberToBig(Left(strDec, 1)) & "角" & dfNumberToBig(Right(strDec, 1)) & "分"
End If
End If
End If
Exit Function
ErrTrap:
On Error GoTo 0
End Function
#2
Private Function dfNumberToBig(ByVal strN As String) As String
Select Case strN
Case "0"
dfNumberToBig = "零"
Case "1"
dfNumberToBig = "壹"
Case "2"
dfNumberToBig = "贰"
Case "3"
dfNumberToBig = "叁"
Case "4"
dfNumberToBig = "肆"
Case "5"
dfNumberToBig = "伍"
Case "6"
dfNumberToBig = "陆"
Case "7"
dfNumberToBig = "柒"
Case "8"
dfNumberToBig = "捌"
Case "9"
dfNumberToBig = "玖"
End Select
End Function
Select Case strN
Case "0"
dfNumberToBig = "零"
Case "1"
dfNumberToBig = "壹"
Case "2"
dfNumberToBig = "贰"
Case "3"
dfNumberToBig = "叁"
Case "4"
dfNumberToBig = "肆"
Case "5"
dfNumberToBig = "伍"
Case "6"
dfNumberToBig = "陆"
Case "7"
dfNumberToBig = "柒"
Case "8"
dfNumberToBig = "捌"
Case "9"
dfNumberToBig = "玖"
End Select
End Function
#3
谢谢楼上的兄弟拉
请问还有什么好的方法不?
请问还有什么好的方法不?
#4
源代码都有了,复制下来用不就行了,这不都是现成的了吗?
#5
谢谢microtry了
我没看懂上面的代码哦。。
能加点注释不啊。。
万分感谢。。。。
我没看懂上面的代码哦。。
能加点注释不啊。。
万分感谢。。。。
#6
同一种程序有很多写法,上面那个算法写得有点麻烦了。等我给你一个简练点的。
#7
建立一个模块,将下面的代码拷贝的模块里。
注意:暂时没实现下面两个功能。
1、零百零十零万的缩位。
2、没有超出长度的处理,超过预期数字长度将导致程序崩溃。如果你把它用在商业用途,一定要小心这个现象。
函数叫ChinaNumericGet,参数是一个Double值。你只要“金额=ChinaNumericGet(数字)”就可以了。至于这个程序具体的原理如果详细说起来比较多,大致就是一个查表法。
我写程序不喜欢用Select和If Then,因为太麻烦,不容易扩展。
如果你把conBitNameTable的值改为“头十百千万十百千亿十百千万十百千兆十百千万十百千亿十百千万十百千”;把Format(pValue, "#.00")改成Format(pValue, "#")。则可以用来给养猪场清点大肥猪。
^_^
Const conBitNameTable As String = "分角元十百千万十百千亿十百千万十百千兆十百千万十百千亿十百千万十百千"
Const conNumericTable As String = "零壹贰叁肆伍陆柒捌玖"
Public Function ChinaNumericGet(ByVal pValue As Double) As String
Dim tOutStr As String
Dim tValueStr As String
Dim tValueBits() As Byte
Dim tValueBitsLen As Long
Dim tValueBitsIndex As Long
tValueStr = Format(pValue, "#.00")
tValueStr = Replace(tValueStr, ".", "")
tValueBits() = StrConv(tValueStr, vbFromUnicode)
tValueBitsLen = UBound(tValueBits())
Dim tValueBitsLenCheck As Boolean
tValueBitsLenCheck = tValueBitsLen > (Len(conBitNameTable) - 1)
Dim tBitStr As String
Dim tBitIndex As Long
For tValueBitsIndex = tValueBitsLen To 0 Step -1
tBitStr = Mid(conNumericTable, tValueBits(tValueBitsIndex) - 47, 1)
tBitIndex = tValueBitsLen - tValueBitsIndex + 1
tBitStr = tBitStr & Mid(conBitNameTable, tBitIndex, 1)
tOutStr = tBitStr & tOutStr
Next
ChinaNumericGet = tOutStr
End Function
注意:暂时没实现下面两个功能。
1、零百零十零万的缩位。
2、没有超出长度的处理,超过预期数字长度将导致程序崩溃。如果你把它用在商业用途,一定要小心这个现象。
函数叫ChinaNumericGet,参数是一个Double值。你只要“金额=ChinaNumericGet(数字)”就可以了。至于这个程序具体的原理如果详细说起来比较多,大致就是一个查表法。
我写程序不喜欢用Select和If Then,因为太麻烦,不容易扩展。
如果你把conBitNameTable的值改为“头十百千万十百千亿十百千万十百千兆十百千万十百千亿十百千万十百千”;把Format(pValue, "#.00")改成Format(pValue, "#")。则可以用来给养猪场清点大肥猪。
^_^
Const conBitNameTable As String = "分角元十百千万十百千亿十百千万十百千兆十百千万十百千亿十百千万十百千"
Const conNumericTable As String = "零壹贰叁肆伍陆柒捌玖"
Public Function ChinaNumericGet(ByVal pValue As Double) As String
Dim tOutStr As String
Dim tValueStr As String
Dim tValueBits() As Byte
Dim tValueBitsLen As Long
Dim tValueBitsIndex As Long
tValueStr = Format(pValue, "#.00")
tValueStr = Replace(tValueStr, ".", "")
tValueBits() = StrConv(tValueStr, vbFromUnicode)
tValueBitsLen = UBound(tValueBits())
Dim tValueBitsLenCheck As Boolean
tValueBitsLenCheck = tValueBitsLen > (Len(conBitNameTable) - 1)
Dim tBitStr As String
Dim tBitIndex As Long
For tValueBitsIndex = tValueBitsLen To 0 Step -1
tBitStr = Mid(conNumericTable, tValueBits(tValueBitsIndex) - 47, 1)
tBitIndex = tValueBitsLen - tValueBitsIndex + 1
tBitStr = tBitStr & Mid(conBitNameTable, tBitIndex, 1)
tOutStr = tBitStr & tOutStr
Next
ChinaNumericGet = tOutStr
End Function
#8
下面是程序的实际运行结果。
输入:1233456789.123
输出:壹十贰亿叁千叁百肆十伍万陆千柒百捌十玖元壹角贰分
输入:1000000000.123
输出:壹十零亿零千零百零十零万零千零百零十零元壹角贰分
输入:1233456789.123
输出:壹十贰亿叁千叁百肆十伍万陆千柒百捌十玖元壹角贰分
输入:1000000000.123
输出:壹十零亿零千零百零十零万零千零百零十零元壹角贰分
#9
楼上的妹妹,程序要给别人用首先确保你的代码是自完备的,否则会导致别人的代码甚至项目崩溃,我的代码7年前写的,虽然不够完美,但至少是安全的代码和没有错误的代码
举个例子:
执行你的代码:Text1.Text = ChinaNumericGet("abc")
结果崩溃:实时错误‘13’类型不匹配
执行我的代码:Text1.Text = dfTransToBig("abc ")
结果:空字符串
其次您的计算结果好象有误啊:
再举个例子
输入:1000050000.123
ChinaNumericGet输出:壹十零亿零千零百零十伍万零千零百零十零元壹角贰分
dfTransToBig输出:壹拾亿伍万圆壹角贰分(这里不需要读出零)
十亿五千万被你转换成“壹十零亿零千零百零十伍万……”
包括你举的1000000000.123的结果,读都读不通
在举个关于读零的例子
输入1005.123
ChinaNumericGet输出:壹千零百零十伍元壹角贰分(还是读不通)
dfTransToBig输出:壹仟零伍圆壹角贰分(这里只读一次零)
顺便说一句,你的“十”应该是“拾”,当然这倒是小问题了
解决这个问题是要求你具备一些基本数学和财务知识的
举个例子:
执行你的代码:Text1.Text = ChinaNumericGet("abc")
结果崩溃:实时错误‘13’类型不匹配
执行我的代码:Text1.Text = dfTransToBig("abc ")
结果:空字符串
其次您的计算结果好象有误啊:
再举个例子
输入:1000050000.123
ChinaNumericGet输出:壹十零亿零千零百零十伍万零千零百零十零元壹角贰分
dfTransToBig输出:壹拾亿伍万圆壹角贰分(这里不需要读出零)
十亿五千万被你转换成“壹十零亿零千零百零十伍万……”
包括你举的1000000000.123的结果,读都读不通
在举个关于读零的例子
输入1005.123
ChinaNumericGet输出:壹千零百零十伍元壹角贰分(还是读不通)
dfTransToBig输出:壹仟零伍圆壹角贰分(这里只读一次零)
顺便说一句,你的“十”应该是“拾”,当然这倒是小问题了
解决这个问题是要求你具备一些基本数学和财务知识的
#10
关注,小鲜美很长时间没来VB版了啊,呵呵
#11
写法的确许多。读法要看楼主具体要求了。
#12
也给贴个示例,如果要向microtry(米醋)那样的读法,可以用replace进一步格式化
Function GetRMB(dMoney As Currency) As String
Dim sMoney As String
Dim sGetRMB As String
Dim sPos As Variant
Dim i As Integer, j As Integer
'格式化
sMoney = Format(dMoney, "##0.00")
'用中文替换阿拉伯数字并去掉小数点
sMoney = Replace(sMoney, "0", "零")
sMoney = Replace(sMoney, "1", "壹")
sMoney = Replace(sMoney, "2", "贰")
sMoney = Replace(sMoney, "3", "叁")
sMoney = Replace(sMoney, "4", "肆")
sMoney = Replace(sMoney, "5", "伍")
sMoney = Replace(sMoney, "6", "陆")
sMoney = Replace(sMoney, "7", "柒")
sMoney = Replace(sMoney, "8", "捌")
sMoney = Replace(sMoney, "9", "玖")
sMoney = Replace(sMoney, ".", vbNullString)
'从字符串的最后一位开始向前插入相应的单位
sGetRMB = "整"
sPos = Array("分", "角", "元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "万", "兆")
For i = Len(sMoney) To 1 Step -1
sGetRMB = Mid(sMoney, i, 1) & sPos(j) & sGetRMB
j = j + 1
Next
If dMoney < 0 Then sGetRMB = "负" & sGetRMB
GetRMB = sGetRMB
End Function
Function GetRMB(dMoney As Currency) As String
Dim sMoney As String
Dim sGetRMB As String
Dim sPos As Variant
Dim i As Integer, j As Integer
'格式化
sMoney = Format(dMoney, "##0.00")
'用中文替换阿拉伯数字并去掉小数点
sMoney = Replace(sMoney, "0", "零")
sMoney = Replace(sMoney, "1", "壹")
sMoney = Replace(sMoney, "2", "贰")
sMoney = Replace(sMoney, "3", "叁")
sMoney = Replace(sMoney, "4", "肆")
sMoney = Replace(sMoney, "5", "伍")
sMoney = Replace(sMoney, "6", "陆")
sMoney = Replace(sMoney, "7", "柒")
sMoney = Replace(sMoney, "8", "捌")
sMoney = Replace(sMoney, "9", "玖")
sMoney = Replace(sMoney, ".", vbNullString)
'从字符串的最后一位开始向前插入相应的单位
sGetRMB = "整"
sPos = Array("分", "角", "元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "万", "兆")
For i = Len(sMoney) To 1 Step -1
sGetRMB = Mid(sMoney, i, 1) & sPos(j) & sGetRMB
j = j + 1
Next
If dMoney < 0 Then sGetRMB = "负" & sGetRMB
GetRMB = sGetRMB
End Function
#13
我的代码只是阐述一种算法,而不是给他用的。既然这样说的话,我就给一个完整的代码好了。
#14
谢谢楼上的大哥大姐了。。
#15
good
#1
Public Function dfTransToBig(ByVal curMoney As Variant) As String
On Error GoTo ErrTrap
If Not IsNumeric(curMoney) Then
Exit Function
End If
dfTransToBig = ""
Dim strMoney As String
Dim strInt As String
Dim strDec As String
Dim strTemp As String
strMoney = Format(Str(curMoney), "#.00")
strInt = Left(strMoney, Len(strMoney) - 3)
strInt = String(12 - Len(strInt), "0") & Trim(strInt)
strDec = Right(strMoney, 2)
strTemp = dfGroupToBig(Mid(strInt, 1, 4))
If strTemp <> "" Then
dfTransToBig = dfTransToBig & strTemp & "亿"
End If
strTemp = dfGroupToBig(Mid(strInt, 5, 4))
If strTemp <> "" Then
dfTransToBig = dfTransToBig & strTemp & "万"
End If
strTemp = dfGroupToBig(Mid(strInt, 9, 4))
If strTemp <> "" Then
dfTransToBig = dfTransToBig & strTemp
End If
dfTransToBig = dfTransToBig & "圆"
If strDec = "00" Then
dfTransToBig = dfTransToBig & "整"
Else
If Left(strDec, 1) = "0" Then
dfTransToBig = dfTransToBig & dfNumberToBig(Right(strDec, 1)) & "分"
Else
If Right(strDec, 1) = "0" Then
dfTransToBig = dfTransToBig & dfNumberToBig(Left(strDec, 1)) & "角"
Else
dfTransToBig = dfTransToBig & dfNumberToBig(Left(strDec, 1)) & "角" & dfNumberToBig(Right(strDec, 1)) & "分"
End If
End If
End If
Exit Function
ErrTrap:
On Error GoTo 0
End Function
On Error GoTo ErrTrap
If Not IsNumeric(curMoney) Then
Exit Function
End If
dfTransToBig = ""
Dim strMoney As String
Dim strInt As String
Dim strDec As String
Dim strTemp As String
strMoney = Format(Str(curMoney), "#.00")
strInt = Left(strMoney, Len(strMoney) - 3)
strInt = String(12 - Len(strInt), "0") & Trim(strInt)
strDec = Right(strMoney, 2)
strTemp = dfGroupToBig(Mid(strInt, 1, 4))
If strTemp <> "" Then
dfTransToBig = dfTransToBig & strTemp & "亿"
End If
strTemp = dfGroupToBig(Mid(strInt, 5, 4))
If strTemp <> "" Then
dfTransToBig = dfTransToBig & strTemp & "万"
End If
strTemp = dfGroupToBig(Mid(strInt, 9, 4))
If strTemp <> "" Then
dfTransToBig = dfTransToBig & strTemp
End If
dfTransToBig = dfTransToBig & "圆"
If strDec = "00" Then
dfTransToBig = dfTransToBig & "整"
Else
If Left(strDec, 1) = "0" Then
dfTransToBig = dfTransToBig & dfNumberToBig(Right(strDec, 1)) & "分"
Else
If Right(strDec, 1) = "0" Then
dfTransToBig = dfTransToBig & dfNumberToBig(Left(strDec, 1)) & "角"
Else
dfTransToBig = dfTransToBig & dfNumberToBig(Left(strDec, 1)) & "角" & dfNumberToBig(Right(strDec, 1)) & "分"
End If
End If
End If
Exit Function
ErrTrap:
On Error GoTo 0
End Function
#2
Private Function dfNumberToBig(ByVal strN As String) As String
Select Case strN
Case "0"
dfNumberToBig = "零"
Case "1"
dfNumberToBig = "壹"
Case "2"
dfNumberToBig = "贰"
Case "3"
dfNumberToBig = "叁"
Case "4"
dfNumberToBig = "肆"
Case "5"
dfNumberToBig = "伍"
Case "6"
dfNumberToBig = "陆"
Case "7"
dfNumberToBig = "柒"
Case "8"
dfNumberToBig = "捌"
Case "9"
dfNumberToBig = "玖"
End Select
End Function
Select Case strN
Case "0"
dfNumberToBig = "零"
Case "1"
dfNumberToBig = "壹"
Case "2"
dfNumberToBig = "贰"
Case "3"
dfNumberToBig = "叁"
Case "4"
dfNumberToBig = "肆"
Case "5"
dfNumberToBig = "伍"
Case "6"
dfNumberToBig = "陆"
Case "7"
dfNumberToBig = "柒"
Case "8"
dfNumberToBig = "捌"
Case "9"
dfNumberToBig = "玖"
End Select
End Function
#3
谢谢楼上的兄弟拉
请问还有什么好的方法不?
请问还有什么好的方法不?
#4
源代码都有了,复制下来用不就行了,这不都是现成的了吗?
#5
谢谢microtry了
我没看懂上面的代码哦。。
能加点注释不啊。。
万分感谢。。。。
我没看懂上面的代码哦。。
能加点注释不啊。。
万分感谢。。。。
#6
同一种程序有很多写法,上面那个算法写得有点麻烦了。等我给你一个简练点的。
#7
建立一个模块,将下面的代码拷贝的模块里。
注意:暂时没实现下面两个功能。
1、零百零十零万的缩位。
2、没有超出长度的处理,超过预期数字长度将导致程序崩溃。如果你把它用在商业用途,一定要小心这个现象。
函数叫ChinaNumericGet,参数是一个Double值。你只要“金额=ChinaNumericGet(数字)”就可以了。至于这个程序具体的原理如果详细说起来比较多,大致就是一个查表法。
我写程序不喜欢用Select和If Then,因为太麻烦,不容易扩展。
如果你把conBitNameTable的值改为“头十百千万十百千亿十百千万十百千兆十百千万十百千亿十百千万十百千”;把Format(pValue, "#.00")改成Format(pValue, "#")。则可以用来给养猪场清点大肥猪。
^_^
Const conBitNameTable As String = "分角元十百千万十百千亿十百千万十百千兆十百千万十百千亿十百千万十百千"
Const conNumericTable As String = "零壹贰叁肆伍陆柒捌玖"
Public Function ChinaNumericGet(ByVal pValue As Double) As String
Dim tOutStr As String
Dim tValueStr As String
Dim tValueBits() As Byte
Dim tValueBitsLen As Long
Dim tValueBitsIndex As Long
tValueStr = Format(pValue, "#.00")
tValueStr = Replace(tValueStr, ".", "")
tValueBits() = StrConv(tValueStr, vbFromUnicode)
tValueBitsLen = UBound(tValueBits())
Dim tValueBitsLenCheck As Boolean
tValueBitsLenCheck = tValueBitsLen > (Len(conBitNameTable) - 1)
Dim tBitStr As String
Dim tBitIndex As Long
For tValueBitsIndex = tValueBitsLen To 0 Step -1
tBitStr = Mid(conNumericTable, tValueBits(tValueBitsIndex) - 47, 1)
tBitIndex = tValueBitsLen - tValueBitsIndex + 1
tBitStr = tBitStr & Mid(conBitNameTable, tBitIndex, 1)
tOutStr = tBitStr & tOutStr
Next
ChinaNumericGet = tOutStr
End Function
注意:暂时没实现下面两个功能。
1、零百零十零万的缩位。
2、没有超出长度的处理,超过预期数字长度将导致程序崩溃。如果你把它用在商业用途,一定要小心这个现象。
函数叫ChinaNumericGet,参数是一个Double值。你只要“金额=ChinaNumericGet(数字)”就可以了。至于这个程序具体的原理如果详细说起来比较多,大致就是一个查表法。
我写程序不喜欢用Select和If Then,因为太麻烦,不容易扩展。
如果你把conBitNameTable的值改为“头十百千万十百千亿十百千万十百千兆十百千万十百千亿十百千万十百千”;把Format(pValue, "#.00")改成Format(pValue, "#")。则可以用来给养猪场清点大肥猪。
^_^
Const conBitNameTable As String = "分角元十百千万十百千亿十百千万十百千兆十百千万十百千亿十百千万十百千"
Const conNumericTable As String = "零壹贰叁肆伍陆柒捌玖"
Public Function ChinaNumericGet(ByVal pValue As Double) As String
Dim tOutStr As String
Dim tValueStr As String
Dim tValueBits() As Byte
Dim tValueBitsLen As Long
Dim tValueBitsIndex As Long
tValueStr = Format(pValue, "#.00")
tValueStr = Replace(tValueStr, ".", "")
tValueBits() = StrConv(tValueStr, vbFromUnicode)
tValueBitsLen = UBound(tValueBits())
Dim tValueBitsLenCheck As Boolean
tValueBitsLenCheck = tValueBitsLen > (Len(conBitNameTable) - 1)
Dim tBitStr As String
Dim tBitIndex As Long
For tValueBitsIndex = tValueBitsLen To 0 Step -1
tBitStr = Mid(conNumericTable, tValueBits(tValueBitsIndex) - 47, 1)
tBitIndex = tValueBitsLen - tValueBitsIndex + 1
tBitStr = tBitStr & Mid(conBitNameTable, tBitIndex, 1)
tOutStr = tBitStr & tOutStr
Next
ChinaNumericGet = tOutStr
End Function
#8
下面是程序的实际运行结果。
输入:1233456789.123
输出:壹十贰亿叁千叁百肆十伍万陆千柒百捌十玖元壹角贰分
输入:1000000000.123
输出:壹十零亿零千零百零十零万零千零百零十零元壹角贰分
输入:1233456789.123
输出:壹十贰亿叁千叁百肆十伍万陆千柒百捌十玖元壹角贰分
输入:1000000000.123
输出:壹十零亿零千零百零十零万零千零百零十零元壹角贰分
#9
楼上的妹妹,程序要给别人用首先确保你的代码是自完备的,否则会导致别人的代码甚至项目崩溃,我的代码7年前写的,虽然不够完美,但至少是安全的代码和没有错误的代码
举个例子:
执行你的代码:Text1.Text = ChinaNumericGet("abc")
结果崩溃:实时错误‘13’类型不匹配
执行我的代码:Text1.Text = dfTransToBig("abc ")
结果:空字符串
其次您的计算结果好象有误啊:
再举个例子
输入:1000050000.123
ChinaNumericGet输出:壹十零亿零千零百零十伍万零千零百零十零元壹角贰分
dfTransToBig输出:壹拾亿伍万圆壹角贰分(这里不需要读出零)
十亿五千万被你转换成“壹十零亿零千零百零十伍万……”
包括你举的1000000000.123的结果,读都读不通
在举个关于读零的例子
输入1005.123
ChinaNumericGet输出:壹千零百零十伍元壹角贰分(还是读不通)
dfTransToBig输出:壹仟零伍圆壹角贰分(这里只读一次零)
顺便说一句,你的“十”应该是“拾”,当然这倒是小问题了
解决这个问题是要求你具备一些基本数学和财务知识的
举个例子:
执行你的代码:Text1.Text = ChinaNumericGet("abc")
结果崩溃:实时错误‘13’类型不匹配
执行我的代码:Text1.Text = dfTransToBig("abc ")
结果:空字符串
其次您的计算结果好象有误啊:
再举个例子
输入:1000050000.123
ChinaNumericGet输出:壹十零亿零千零百零十伍万零千零百零十零元壹角贰分
dfTransToBig输出:壹拾亿伍万圆壹角贰分(这里不需要读出零)
十亿五千万被你转换成“壹十零亿零千零百零十伍万……”
包括你举的1000000000.123的结果,读都读不通
在举个关于读零的例子
输入1005.123
ChinaNumericGet输出:壹千零百零十伍元壹角贰分(还是读不通)
dfTransToBig输出:壹仟零伍圆壹角贰分(这里只读一次零)
顺便说一句,你的“十”应该是“拾”,当然这倒是小问题了
解决这个问题是要求你具备一些基本数学和财务知识的
#10
关注,小鲜美很长时间没来VB版了啊,呵呵
#11
写法的确许多。读法要看楼主具体要求了。
#12
也给贴个示例,如果要向microtry(米醋)那样的读法,可以用replace进一步格式化
Function GetRMB(dMoney As Currency) As String
Dim sMoney As String
Dim sGetRMB As String
Dim sPos As Variant
Dim i As Integer, j As Integer
'格式化
sMoney = Format(dMoney, "##0.00")
'用中文替换阿拉伯数字并去掉小数点
sMoney = Replace(sMoney, "0", "零")
sMoney = Replace(sMoney, "1", "壹")
sMoney = Replace(sMoney, "2", "贰")
sMoney = Replace(sMoney, "3", "叁")
sMoney = Replace(sMoney, "4", "肆")
sMoney = Replace(sMoney, "5", "伍")
sMoney = Replace(sMoney, "6", "陆")
sMoney = Replace(sMoney, "7", "柒")
sMoney = Replace(sMoney, "8", "捌")
sMoney = Replace(sMoney, "9", "玖")
sMoney = Replace(sMoney, ".", vbNullString)
'从字符串的最后一位开始向前插入相应的单位
sGetRMB = "整"
sPos = Array("分", "角", "元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "万", "兆")
For i = Len(sMoney) To 1 Step -1
sGetRMB = Mid(sMoney, i, 1) & sPos(j) & sGetRMB
j = j + 1
Next
If dMoney < 0 Then sGetRMB = "负" & sGetRMB
GetRMB = sGetRMB
End Function
Function GetRMB(dMoney As Currency) As String
Dim sMoney As String
Dim sGetRMB As String
Dim sPos As Variant
Dim i As Integer, j As Integer
'格式化
sMoney = Format(dMoney, "##0.00")
'用中文替换阿拉伯数字并去掉小数点
sMoney = Replace(sMoney, "0", "零")
sMoney = Replace(sMoney, "1", "壹")
sMoney = Replace(sMoney, "2", "贰")
sMoney = Replace(sMoney, "3", "叁")
sMoney = Replace(sMoney, "4", "肆")
sMoney = Replace(sMoney, "5", "伍")
sMoney = Replace(sMoney, "6", "陆")
sMoney = Replace(sMoney, "7", "柒")
sMoney = Replace(sMoney, "8", "捌")
sMoney = Replace(sMoney, "9", "玖")
sMoney = Replace(sMoney, ".", vbNullString)
'从字符串的最后一位开始向前插入相应的单位
sGetRMB = "整"
sPos = Array("分", "角", "元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "万", "兆")
For i = Len(sMoney) To 1 Step -1
sGetRMB = Mid(sMoney, i, 1) & sPos(j) & sGetRMB
j = j + 1
Next
If dMoney < 0 Then sGetRMB = "负" & sGetRMB
GetRMB = sGetRMB
End Function
#13
我的代码只是阐述一种算法,而不是给他用的。既然这样说的话,我就给一个完整的代码好了。
#14
谢谢楼上的大哥大姐了。。
#15
good