在PB打印中实现人民币大写 |
根据我国的财务票据的当前特点,仍需要财务票据中人民币有大写一项。本人原来在利用FOXPROW开发系统时,曾经利用FOXPROW编写过人民币大写的函数。现在本人又利用PB编写了一个人民币大写的函数。您只要将您数据窗口中的人民币小写项数据值取出,利用我的这个函数将其转换成大写方式,然后再赋到数据窗口的某项中即可。 函数名:自定义函数:no_to_char_sell() 函数内容: string hz[15] string money[2] //hz[16]='零' 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, num2 val=num do while left(val,1) = '0' val = right(val,len(val)-1) loop if pos(val,'.') < > 0 then num = left(val,pos(val,'.') - 1) num2 =mid(val, pos(val,'.') + 1) end if string str='',str_tmp int i for i= 1 to len(num) str_tmp=mid(num,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(num) then str=str else str=str+'零' end if else choose case len(num) -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(num) -i +1 = 9 and mid (num ,len(num) - 8,1) ='0' then if right(str,2)='零' then str = left(str,len(str) - 2) str=str +'亿' end if if len(num) -i +1 = 5 and mid (num ,len(num) - 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 return str |