delphi 金額轉換

2021-04-14 02:00:34 字數 1886 閱讀 1915

procedure tfmbmzc.bitbtn2click(sender: tobject); //金額轉換

const

chnum : array[0..9] of string = ('零','壹','貳','叄','肆','伍','陸','柒','捌','玖');

chbit : array[0..3] of string = ('圓','拾','佰','仟');

vary, m, d : word;

s : string;

len, n , tmp: integer;

biszero : boolean;

begin

decodedate(date, y, m, d);

jfjechange();

with fmprint do begin

qryear.caption:=inttostr(y);

qrmonth.caption:=inttostr(m);

qrday.caption:=inttostr(d);

qrname.caption:=edname.text;

qrxmoney.caption:=jf;

//對照表生成小寫金額的大寫

biszero:=false;

n:=pos('.', jf); //小數點前的處理

if n=0 then

len:=length(jf)

else

len:=n-1;

for n:=1 to len do begin

tmp:=strtoint(jf[n]);

if tmp=0 then begin

if nif length(jf)>len then begin //小數點後的處理

if len+2<=length(jf) then begin

tmp:=strtoint(jf[len+2]);

if tmp=0 then

s:=s+'零'

else

s:=s+chnum[tmp]+'角';

end;

if len+3<=length(jf) then

s:=s+chnum[strtoint(jf[len+3])]+'分';

end;

qrdmoney.caption:=s;

qrshow.caption:='輔修

報名註冊費。';

qrhandler.caption:='僧格淋沁';

quickrep1.preview;

end;

end;

procedure tfmbmzc.jfjechange();  //對輸入框中內容的控制

vartmp : string;

begin

//計算"繳費金額"

jf:=trim(copy(medjfje.text, 1, 4));

if jf='' then //"元"為空

jf:='0';

tmp:=trim(copy(medjfje.text, 7, 1));

if tmp='' then begin file://"角"為空

tmp:=trim(copy(medjfje.text, 10, 1));

if tmp<>'' then //填寫了"分"

jf:=jf+'.0'+tmp;

endelse begin //填寫了"角"

jf:=jf+'.'+tmp;

tmp:=trim(copy(medjfje.text, 10, 1));

if tmp<>'' then //填寫了"分"

jf:=jf+tmp;

end;

jf:=floattostr(strtofloat(jf));

end;

end. 

java金額轉換

author wu 將乙個數字轉化為金額 public class convertnumber 定義陣列存放位數的大寫 private final static string str modify 轉化整數部分 param tempstring return 返回整數部分 private stati...

金額大寫轉換

use toy go object storedprocedure dbo l2u script date 03 19 2014 13 15 27 set ansi nulls on goset quoted identifier on goalter procedure dbo l2u n low...

小寫金額轉換為大寫金額

我的乙個朋友寫的,金額轉成大寫 public static string convertmoney decimal dnum string str2 new string string strunit string.join str1 string struppernum string.join s...