FastReport 金額大小寫轉換自定義函式

2022-09-15 01:39:13 字數 1566 閱讀 4427

在fastreport中編寫金額數字轉換大寫自定義函式

function moneytocharacter(money:real):string; //數字轉換為中文大寫

vartemp:string;

resu:string;

i,j:integer;

len:integer;

num:array[0..9] of string;

a:array[0..13] of string;

begin

num[0]:='零';

num[1]:='壹';

num[2]:='貳';

num[3]:='叄';

num[4]:='肆';

num[5]:='伍';

num[6]:='陸';

num[7]:='柒';

num[8]:='捌';

num[9]:='玖';

a[0]:='分';

a[1]:='角';

a[2]:='元';

a[3]:='拾';

a[4]:='佰';

a[5]:='仟';

a[6]:='萬';

a[7]:='拾';

a[8]:='佰';

a[9]:='仟';

a[10]:='億';

a[11]:='拾';

a[12]:='佰';

a[13]:='仟';

temp:=trim(inttostr(round(money*100)));

len:=length(temp);

resu:='';

if (len>13) or (len=0) then

begin

exit;

end;

for i:=1 to len do

begin

j:=strtoint(copy(temp,i,1));

resu:=resu+num[j]+a[len-i];

end;

len:=length(resu);

result:=copy(resu,0,len-8);

end;

四捨五入,取整數

呼叫函式

procedure memo41onafterdata(sender: tfrxcomponent);

begin

memo41.text:='總金額(大寫):'+moneytocharacter(round(sum(《加工."發貨金額">,masterdata1)))+'整';

tfrxmemoview(sender).font.size:=12;

while ((tfrxmemoview(sender).calcheight-tfrxmemoview(sender).linespacing)-tfrxmemoview(sender).height>0) do

begin

tfrxmemoview(sender).font.size := tfrxmemoview(sender).font.size-1;

end;

end;

如下顯示:

金額大小寫轉換!

把數字轉換成中文大寫金額,分以下小數截位 param dblmoney double 數字 param blnfull boolean false,2001.30 貳仟零壹元叄角整 true,2001.30 貳仟零佰零拾壹元叄角零分 param bzheng boolean 是否強制末尾加整字 如果...

人民幣金額大小寫轉換

大家在編寫涉及到金額的程式的時候,有時候需要將小寫的人民幣金額轉換成大寫表示 下面的 介紹了轉換的實現過程,大家可以參考一下 pragma warning disable 4786 include include include include using std vector using std ...

java android 金額大小寫資料的轉換

public class change 數字金額大寫轉換,思想先寫個完整的然後將如零拾替換成零 要用到正規表示式 public static string digituppercase double n string digit string unit string head n 0?負 n mat...