$pbexportheader$gf_getmoney.srf
$pbexportcomments$獲取金額的大寫格式
global type gf_getmoney from function_object
end type
forward prototypes
global function string gf_getmoney (decimal dsum)
end prototypes
global function string gf_getmoney (decimal dsum);
/*---------------------------------
--功能描述:獲取乙個金額的大寫格式
--引數及返回值說明: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 thenupper = upper + mid(upper1,i*2+1,2) +"角"
end choose
return upper + "整"
end function
格式化金額以及數字金額轉為大寫金額 前端
效果展示 格式化金額用於票據上面顯示 function formatemoney money b g,獲取整數部分 str arr 0 獲取到 字串長度 var len str.length 總長度 9 減去 len 2 剩下就是補得空格數 var count 9 len 2 for var i 1...
數字金額轉為大寫金額
金額轉大寫 public class moneyconvertchinese string strlower null string strupart null string strupper null int itemp 0 保留兩位小數 123.489 123.49 123.4 123.4 lo...
數字金額轉化大寫金額
數字金額轉化大寫金額 param val string number 字串可包含 和多餘的0 returns 原生方法 如下所示 function convertcurrency money if typeof money string if money maxnum if money 0 轉換為字...