PowerBuilder -- 数字金额大写
Posted yarightok
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PowerBuilder -- 数字金额大写相关的知识,希望对你有一定的参考价值。
//==================================================================== // 事件: .pub_fc_change_number() //-------------------------------------------------------------------- // 描述: 数字转换成大写 //-------------------------------------------------------------------- // 参数: // decimal number //-------------------------------------------------------------------- // 返回: string//-------------------------------------------------------------------- // 修改历史: // //==================================================================== String cn_num[10] = {"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"} //大写0-9 String cn_carry[19] = {"分","角","","元","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟","万","拾","佰","仟"} //单位 String ls_pos,ls_old,ls_number,ls_rc = ‘‘, ls_zero, ls_zero_unit Integer li_i,li_len //循环变量 String ls_zf = ‘‘ //正负符号 String ls_value, ls_z Boolean lb_zero_yuan //参数格式化 If ade_number < 0 Then ls_zf = ‘负‘ ade_number = (-1)*ade_number End If ls_number = String(ade_number,"0.00") //参数的长度 li_len = Len(ls_number) ls_zero = ‘‘ ls_zero_unit = ‘‘ lb_zero_yuan = False ls_z = ‘‘ //转换为大写(发票格式),从右到左 For li_i = 1 To li_len ls_value = Mid(ls_number, li_len - li_i + 1, 1) If li_i = 1 And ls_value = ‘0‘ Then // 分 为0 ls_z = ‘整‘ Continue End If If li_i = 2 And ls_value = ‘0‘ And ls_z <> ‘整‘ Then // 角 为0, 分不为 0 ls_rc = ‘零‘ + ls_rc Continue End If // 小数点 If li_i = 3 Then Continue // 万与元,亿与万之间 存在 0 If (li_i = 8 Or li_i = 12) And ls_zero = ‘零‘ Then ls_rc = ‘零‘ + ls_rc ls_zero = ‘‘ End If // 元 万 亿 为0 If li_len > 4 And (li_i = 4 Or li_i = 8 Or li_i = 12) And ls_value = ‘0‘ Then ls_rc = cn_carry[li_i] + ls_rc lb_zero_yuan = True Continue End If // 万与元,亿与万之间 存在 0 If li_len > 5 And li_i > 4 And ls_value = ‘0‘ And ls_zero = ‘‘ And Not lb_zero_yuan Then ls_zero = ‘零‘ End If If ls_value <> ‘0‘ Or li_i = 4 Then ls_rc = cn_num[1 + Mod(Integer(ls_value), 10)] + cn_carry[li_i] + ls_zero + ls_rc ls_zero = ‘‘ lb_zero_yuan = False End If Next ls_rc = ls_zf + ls_rc + ls_z Return ls_rc //返回结果 100100.11 100100100.11 10010100100.11
以上是关于PowerBuilder -- 数字金额大写的主要内容,如果未能解决你的问题,请参考以下文章