| 導購 | 订阅 | 在线投稿
分享
 
 
 

將小寫數字金額轉成大寫金額

來源:互聯網  2008-06-01 01:15:10  評論

procedure TfmBMZC.BitBTn2Click(Sender: TObject); //金額轉換

const

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

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

var

y, 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 n<len then

bIsZero:=true

else if n=len then

s:=s + chBit[len-n];

end

else begin

if bIsZero then begin

s:=s+chNum[0]+chNum[tmp] + chBit[len-n];

bIsZero:=false;

end

else

s:=s+chNum[tmp] + chBit[len-n];

end;

end;

if 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(); //對輸入框中內容的控制

var

tmp : 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;

end

else begin //填寫了"角"

jf:=jf+'.'+tmp;

tmp:=Trim(Copy(mEdJFJE.Text, 10, 1));

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

jf:=jf+tmp;

end;

jf:=FloatToStr(StrToFloat(jf));

end;

end.

procedure TfmBMZC.BitBTn2Click(Sender: TObject); //金額轉換 const chNum : array[0..9] of string = ('零','壹','貳','叁','肆','伍','陸','柒','捌','玖'); chBit : array[0..3] of string = ('圓','拾','佰','仟'); var y, 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 n<len then bIsZero:=true else if n=len then s:=s + chBit[len-n]; end else begin if bIsZero then begin s:=s+chNum[0]+chNum[tmp] + chBit[len-n]; bIsZero:=false; end else s:=s+chNum[tmp] + chBit[len-n]; end; end; if 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(); //對輸入框中內容的控制 var tmp : 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; end else begin //填寫了"角" jf:=jf+'.'+tmp; tmp:=Trim(Copy(mEdJFJE.Text, 10, 1)); if tmp<>' then //填寫了"分" jf:=jf+tmp; end; jf:=FloatToStr(StrToFloat(jf)); end; end.
󰈣󰈤
王朝萬家燈火計劃
期待原創作者加盟
 
 
 
>>返回首頁<<
 
 
 
 
 熱帖排行
 
 
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有