|
金额大写转换(1)
看到前面的金额转换,一时兴起也动手写了一个,写的匆忙支持的位数不多,有错误的地方还请多多指教。入口:getChangedVal Option EXPlicit '总体思路: '对数字进行分级处理,级长为4 '对分级后的每级分别处理,处理后得到字符串相连 '如:123456=123456 '第二级:12=壹拾贰 + “万” '第一级:3456 =叁千肆百伍拾陆 + “” Private Const PrvStrNum = "壹贰叁肆伍陆柒捌玖零" Private Const PrvStrUnit = "万千百拾个" Private Const PrvStrGradeUnit = "千万亿兆" '"兆亿万千" Private Const PrvGrade = 4 Public Function getChangedVal(ByVal StrVal As String) As String Dim StrDotUnit As String Dim StrIntUnit As String StrDotUnit = getDotUnit(StrVal) '取小数位 StrIntUnit = getIntUnit(StrVal) '取整数位 StrIntUnit = getIntUpper(StrIntUnit) '整数位转换大写 StrDotUnit = getDotUpper(StrIntUnit) '小数位转换大写 getChangedVal = StrIntUnit & StrDotUnit End Function
Private Function getDotUnit(ByVal StrVal As String) As String '得到小数点后的数字 Dim StrRet As String Dim IntBegin As Integer Dim IntLen As Integer IntBegin = InStr(1, StrVal, ".") + 1 IntLen = Len(StrVal) + 1 StrRet = Mid(StrVal, IntBegin, IntLen - IntBegin) If IntBegin > 1 Then getDotUnit = StrRet End If End Function Private Function getIntUnit(ByVal StrVal As String) As String '得到整数数字 Dim StrRet As String Dim IntBegin As Integer Dim IntLen As Integer '取得小数数位的长度 IntBegin = Len(getDotUnit(StrVal))
|