Function ChinaYuan(Amt: Extended): String;
var
C_U : Array[0..10] of String;
C_D : Array[0..10] Of String;
B_point_c: string;
A_point_c: string;
Chinese_st: String;
temp1: String;
temp2: String;
B_point : Real;
A_point : Real;
i:integer;
c,mark : char;
label
bbbb;
begin
C_U[0]:='元';
C_U[1]:='拾';
C_U[2]:='百';
C_U[3]:='仟';
C_U[4]:='万';
C_U[5]:='拾';
C_U[6]:='百';
C_U[7]:='仟';
C_U[8]:='万';
C_D[0]:='零';
C_D[1]:='壹';
C_D[2]:='贰';
C_D[3]:='叁';
C_D[4]:='肆';
C_D[5]:='伍';
C_D[6]:='陆';
C_D[7]:='柒';
C_D[8]:='捌';
C_D[9]:='玖';
mark:='0';
Try
If amt>=0 Then amt:=amt+0.005
Else Begin amt:=amt - 0.005;
mark:='1';
amt:=-amt;
End;
except
amt:=0;
end;
B_point := int(amt);
A_point := frac(amt);
B_point_c:= Floattostr(B_point);
A_point_c:= copy(FloatToStrF(int(A_point*100)/100, ffFixed, 4, 2), 3, 2);
i:=1;
If B_point <> 0 Then
Begin
While i<=length(B_point_c) Do
begin
if (copy(B_point_c,i,1)='0') and (copy(B_point_c,i+1,1) = '0') then
begin
temp1:=copy(B_point_c,1,i-1);
temp2:=copy(b_point_c,i+1,length(B_point_c));
B_point_c:=concat(temp1,'!');
B_point_c:=concat(B_point_c,temp2);
end;
i:=i+1;
end;
i:=0;
while i<length(B_point_c) do
begin
temp1:= Copy(B_point_c,Length(b_point_c)-i,1);
c := temp1[1];
Case c of
'0':Begin If (i=0) then Chinese_st := concat('元',Chinese_st)
Else Chinese_st := concat(C_D[strtoint(temp1)],Chinese_st);
If (i=4) or (i=8) then Chinese_st := concat('万',Chinese_st);
End;
'!':If (i=4) or (i=8) then Chinese_st := concat('万',Chinese_st);
else
Begin
Chinese_st := concat(C_U,Chinese_st);
Chinese_st := concat(C_D[strtoint(temp1)],Chinese_st);
end;
end;
i := i+1;
end;
End;
If A_point_c <> '00' then
Begin
temp1:= copy(A_point_c,1,1);
temp2:= copy(A_point_c,2,1);
If temp1 = '0' then
begin
If Chinese_st = '' then
begin
Chinese_st := concat(Chinese_st,C_D[strtoint(temp2)]);
Chinese_st := concat(Chinese_st,'分');
end
Else
begin
Chinese_st := concat(Chinese_st,C_D[strtoint(temp1)]);
Chinese_st := concat(Chinese_st,C_D[strtoint(temp2)]);
Chinese_st := concat(Chinese_st,'分');
End;
goto bbbb;
end;
if temp2 = '0' then
begin
Chinese_st := concat(Chinese_st,C_D[strtoint(temp1)]);
Chinese_st := concat(Chinese_st,'角');
Chinese_st := concat(Chinese_st,'整');
goto bbbb;
end;
Chinese_st := concat(Chinese_st,C_D[strtoint(temp1)]);
Chinese_st := concat(Chinese_st,'角');
Chinese_st := concat(Chinese_st,C_D[strtoint(temp2)]);
Chinese_st := concat(Chinese_st,'分');
end
Else If Chinese_st <> '' Then Chinese_st := concat(Chinese_st,'整')
Else Chinese_st := concat(Chinese_st,'无');
bbbb:
If mark = '1' Then Chinese_st := concat('负',Chinese_st);
Result:= chinese_st;
end;