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 -- 数字金额大写的主要内容,如果未能解决你的问题,请参考以下文章

PHP数字金额转换大写金额

java实现数字金额转换成汉字大写金额

小写金额怎样生成大写

Java中金额数字转换为大写数字

关于数字金额转换大写金额,sql语句

js怎么把数字金额转换成中文大写金额