//====================================================================
// Event: f_convert
//--------------------------------------------------------------------
// Description: 转换成大写
//--------------------------------------------------------------------
// Arguments:
// value decimal num
// value boolean rmb
//--------------------------------------------------------------------
// Returns: string
//--------------------------------------------------------------------
// Author: jiamr Date: 2018-11-16
//--------------------------------------------------------------------
// Modify History:
//
//====================================================================
string hz[15]
string money[2] //hz[16]=‘零’
integer li_long
if not rmb then
hz[1]=‘一’
hz[2]=‘二’
hz[3]=‘三’
hz[4]=‘四’
hz[5]=‘五’
hz[6]=‘六’
hz[7]=‘七’
hz[8]=‘八’
hz[9]=‘九’
hz[10]=‘十’
hz[11]=‘百’
hz[12]=‘千’
hz[13]=‘万’
hz[14]=‘亿’
hz[15]=‘点’
else
hz[1]=‘壹’
hz[2]=‘贰’
hz[3]=‘叁’
hz[4]=‘肆’
hz[5]=‘伍’
hz[6]=‘陆’
hz[7]=‘柒’
hz[8]=‘捌’
hz[9]=‘玖’
hz[10]=‘拾’
hz[11]=‘佰’
hz[12]=‘仟’
hz[13]=‘万’
hz[14]=‘亿’
hz[15]=‘元’
money[1]=‘角’
money[2]=‘分’
end if
string val,num1, num2
num1=trim(string(round(num,2)))
val=num1
do while left(val,1) = ‘0’
val = right(val,len(val)-1)
loop
if pos(val,’.’) <> 0 then
num1 = left(val,pos(val,’.’) - 1)
num2 =mid(val, pos(val,’.’) + 1)
end if
string str=’’,str_tmp
int i
for i= 1 to len(num1)
str_tmp=mid(num1,i,1)
choose case str_tmp
case ‘1’
str=str+hz[1]
case ‘2’
str=str+hz[2]
case ‘3’
str=str+hz[3]
case ‘4’
str=str+hz[4]
case ‘5’
str=str+hz[5]
case ‘6’
str=str+hz[6]
case ‘7’
str=str+hz[7]
case ‘8’
str=str+hz[8]
case ‘9’
str=str+hz[9]
case ‘0’
str=str+’’
end choose
if str_tmp=‘0’ then
if right(str,2)=‘零’ or str=’’ or i=len(num1)then
str=str
else
str=str+‘零’
end if
else
choose case len(num1) -i +1
case 1
str=str
case 2,6,10
str=str +hz[10]
case 3,7,11
str=str +hz[11]
case 4,8,12
str=str +hz[12] //千
case 5,13
str=str +hz[13] //‘万’
case 9
str=str +‘亿’
end choose
end if
if len(num1) -i +1 = 9 and mid (num1 ,len(num1) - 8,1) =‘0’ then
if right(str,2)=‘零’ then str=left(str,len(str) - 2)
str=str +‘亿’
end if
if len(num1) -i +1 = 5 and mid (num1 ,len(num1) - 4 ,1) =‘0’ then
if right(str,2)=‘零’ then str = left(str,len(str) - 2)
str=str +‘万’
end if
next
if right(str,2)=‘零’ then
str = left(str,len(str) - 2)
end if
if left(str,4) =‘一十’ or left(str,4) =‘壹拾’ then str = right(str,len(str) - 2)
int lpos
lpos = pos(str,‘亿万’)
if lpos <> 0 then
str =left(str , lpos +1) +mid(str,lpos +4)
end if
if pos(val,’.’) =0 then
if rmb then
return str+hz[15]
else
return str
end if
end if
str = str + hz[15] //点or 元
int il_i
il_i = len(num2)
if rmb and il_I > 2 then
il_i = 2
end if
for i= 1 to il_i
str_tmp=mid(num2,i,1)
choose case str_tmp
case ‘1’
str=str+hz[1]
case ‘2’
str=str+hz[2]
case ‘3’
str=str+hz[3]
case ‘4’
str=str+hz[4]
case ‘5’
str=str+hz[5]
case ‘6’
str=str+hz[6]
case ‘7’
str=str+hz[7]
case ‘8’
str=str+hz[8]
case ‘9’
str=str+hz[9]
case ‘0’
str=str+‘零’
end choose
if rmb and right(str,2) <> ’ 零’ then str=str+money[i]
next
do while right(str,2) = ‘零’
str = left(str,len(str) - 2)
loop
if right(str,2)=‘点’ then str=left(str,len(str) - 2)
if rmb then
li_long =len(str)
if mid(str,li_long - 7,2)=‘零’ then //去角
str=left(str,li_long - 8) +right(str,4)
end if
li_long=len(str)
if mid(str,li_long - 3,2)=“零” then //去分
str=left(str, li_long - 4)
end if
str=str + “整”
else
str=str +“元”
end if
return str