|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 YZC51 于 2019-12-21 22:06 编辑
学习LDY 和 大理 两位版主的代码。谢谢老师们!
Function DxToN(ss)
For i% = 1 To 9
ss = Replace(ss, Mid("壹贰叁肆伍陆柒捌玖", i, 1), i)
ss = Replace(ss, Mid("一二三四五六七八九", i, 1), i)
Next
For i% = Len(ss) To 1 Step -1
s$ = Mid$(ss, i, 1)
X% = InStr("分角圆拾佰仟万000亿000兆", s)
If X = 0 Then X% = InStr("0毛元十百千萬000億", s)
If X = 0 Then X% = InStr("00块", 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
DxToN = Round(m, 2)
If InStr(ss, "-") Or InStr(ss, "负") Then DxToN = -DxToN
End Function |
|