PB实现人民币大写转换函数

本文介绍了一个函数,用于将输入的实数值转换为中文大写金额字符串,包括整数部分和小数部分。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



//------------------------------------------
//gf_cm_upper_number(decimal  ar_amount) return string
// 参数ar_amount,类型 decimal
// 返回值类型 string
//
//-------------------------------------------
string ls_input
integer li_strlen, li_cursor, li_count
string ls_result, ls_digit
integer li_digit

//String constant
string ls_const_CC_number[] = {"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"}
string ls_const_CC_Unit[] = {"", "拾", "佰", "仟","万","拾","佰","仟","亿","拾","佰","仟"}
string ls_yuan = "元", ls_jiao = "角", ls_fen = "分", ls_negtive = "负"

//Convert the input real value to string
ls_input = string(abs(ar_amount), "0.00")
li_strlen = len(ls_input)

//Generate Integer part
ls_result = ls_yuan
li_count = 0
FOR li_cursor = li_strlen - 3 TO 1 STEP -1
 li_count = li_count + 1
 ls_digit = mid(ls_input, li_cursor, 1)

 //Get the index of the table number
 li_digit = Integer(ls_digit)
 ls_result = ls_const_CC_number[li_digit + 1] + &
 ls_const_CC_Unit[li_count] + ls_result
NEXT

If double(mid(ls_input,li_strlen -2,2)) = 0 then
 ls_result = ls_result + '整'
Else
 ls_digit = mid(ls_input, li_strlen - 1, 1)
 li_digit = Integer(ls_digit)
 ls_result = ls_result + ls_const_CC_number[li_digit + 1] + ls_jiao
 ls_digit = mid(ls_input, li_strlen , 1)
 li_digit = Integer(ls_digit)
 ls_result = ls_result + ls_const_CC_number[li_digit + 1] + ls_fen
End if

IF ar_amount < 0 THEN
 ls_result = ls_negtive + ls_result
END IF

RETURN ls_result

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值