pb 数字转化为大写金额


/*---------------------------------
--功能描述:获取一个金额的大写格式
--参数及返回值说明:dsum:decimal类型
--      returnvaleu:string类型
---------------------------------*/

boolean digit = false
int     i,n,length
string  temp,temp1,temp2,upper1,upper2,upper = ""
upper1 = '零壹贰叁肆伍陆柒捌玖'
upper2 = '元拾佰仟万拾佰仟亿'
temp = string(dsum,"###.##")
length = len(temp)
if pos(temp,".")>0 then
   temp1 = left(temp,pos(temp,".") - 1)
   temp2 = right(temp,length - pos(temp,"."))
 if integer(temp2) = 0 then temp2=""
else
 temp1 = temp
 temp2 =""
end if
length = len(temp1)
temp  = ""
for i = 1 to length
   n = integer(mid(temp1, i, 1))
 if n=0 then    //digit: true 表示上一数字为0
  digit = true
  continue
 end if
 if digit then temp = "零" + mid(upper1, n * 2 + 1, 2) else temp = mid(upper1, n * 2 + 1, 2)
 digit = false
   upper = upper + temp +  mid(upper2, (length - i) * 2 + 1, 2)
next
if digit then upper = upper + "元"
temp=""
length = len(temp2)
choose case length
 case 2
  n=integer(right(temp2,1))
  if n>0 then temp= mid(upper1,n*2+1,2) +"分"
  i=integer(left(temp2,1))
  if i>0 then upper = upper + mid(upper1,i*2+1,2) +"角" else upper = upper + mid(upper1,i*2+1,2)
  upper = upper + temp
 case 1
  i=integer(left(temp2,1))
  if i>0 then upper = upper + mid(upper1,i*2+1,2) +"角"
end choose
return upper + "整"

转载于:https://www.cnblogs.com/kuailewangzi1212/archive/2010/10/17/1853667.html

你可能感兴趣的:(pb 数字转化为大写金额)