|
本帖最后由 YZC51 于 2019-12-20 19:06 编辑
请参考
'Private
Function ToN(ss) '学习大理版主的代码。谢谢老师!
If Len(ss) = 0 Then ToN = "": Exit Function
xsd = InStr(ss & ".", "."): xs = Mid(ss, xsd + 1) '中文财务及大小写数字转阿拉伯数字
ss = Mid(ss, 1, xsd - 1) & "圆"
For i% = 1 To 9
ss = Replace(ss, Mid("壹贰叁肆伍陆柒捌玖", i, 1), i) '取中文大写整数
ss = Replace(ss, Mid("一二三四五六七八九", i, 1), i) '取中文小写整数
If Len(xs) = 0 Then GoTo xx
xs = Replace(xs, Mid("壹贰叁肆伍陆柒捌玖", i, 1), i) '取中文大写小数
xs = Replace(xs, Mid("一二三四五六七八九", i, 1), i) '取中文小写小数
xx:
Next
xs = "0." & xs '合成小数
For i% = Len(ss) To 1 Step -1 '生成占位 0
s$ = Mid$(ss, i, 1)
x% = InStr("分角圆拾佰仟万 亿 兆", s)
If x = 0 Then x% = InStr(" 毛元十百千萬 億", s)
If x Then j% = IIf(j% < x, x, ((j - 3) \ 4) * 4 + x)
If Val(s) Then m# = m# + (s & String(j - 1, "0")) / 100
Next
ToN = m + xs: If InStr(ss, "-") Or InStr(ss, "负") Then ToN = -ToN
End Function
|
评分
-
1
查看全部评分
-
|