function TFunctions.CovertMoney(Money: Extended): String;Var sStr, buf, sPower, buf1 : String;
i, j, iPosition, lenth, iTmp : Integer;
flag0 : boolean;
Function Sjoin(Var buff : String;
sString : String;
digit : String;
nextdig : String;
iPos : Integer) : Integer;
Var dig : String;
// * 1 flag0 : Boolean;
begin
flag0 := True;
If digit = '0' then
If nextdig <> '0' then
dig := '零' else
flag0 := False;
If digit = '1' then
dig := '壹';
If digit = '2' then
dig := '贰';
If digit = '3' then
dig := '叁';
If digit = '4' then
dig := '肆';
If digit = '5' then
dig := '伍';
If digit = '6' then
dig := '陆';
If digit = '7' then
dig := '柒';
If digit = '8' then
dig := '捌';
If digit = '9' then
dig := '玖';
If digit = '0' then
If (flag0 = True) And (iPos <> 0) then
begin
buff := buff + dig;
Result := 2;
End else
Result := 0 else
begin
buff := buff + dig;
buff := buff + sString;
Result := 4;
end;
end;
begin
If money = 0 then
begin
Result := '零元整';
exit;
end;
iPosition := 0;
buf1 := trim(Format('%12.2f', [money]));
lenth := Length(buf1);
buf := ' ';
// 16 bit space;
j := 1;
For i := 16 - lenth To 15 do
begin
buf := buf1[j];
j := j + 1;
end;
For i := 1 To 15 do
begin
iTmp := ord(buf);
If ((iTmp >= 49) And (iTmp <= 58)) Or (chr(iTmp) = ',') then
break;
end;
While i <= 15 do
begin
flag0 := True;
iTmp := 0;
Case i - 1 Of 0, 4, 8 : sPower := '仟';
1, 5, 9 : sPower := '佰';
2, 6, 10 : sPower := '拾';
3 : begin
sPower := '亿';
If copy(buf, i, 1) = '0' then
begin
sStr := sStr + sPower+'零';
iPosition := iPosition + 2;
iTmp := 1;
end;
end;
7 : begin
sPower := '万';
If copy(buf, i, 1) = '0' then
begin
sStr := sStr + sPower+'零';
iPosition := iPosition + 2;
iTmp := 1;
end;
end;
11 : begin
sPower := '元';
If (copy(buf, i, 1) = '0') And (iPosition <> 0) then
begin
sStr := sStr + sPower;
iPosition := iPosition + 2;
iTmp := 1;
end;
end;
12 : begin
flag0 := False;
If (copy(buf, i + 1, 1) = '0') And (copy(buf, i + 2, 1) = '0') then
begin
sPower := '整';
sStr := sStr + sPower;
iPosition := iPosition + 2;
iTmp := 2;
end;
end;
13 : sPower := '角';
14 : begin
If copy(buf, i, 1) = '0' then
iTmp := 2;
sPower := '分';
end;
end;
If (flag0 = True) And (iTmp = 0) then
begin
If i > 0 then
iPosition := iPosition + Sjoin(sStr, sPower, copy(buf, i, 1), copy(buf, i + 1, 1), iPosition) else
iPosition := iPosition + Sjoin(sStr, sPower, copy(buf, i, 1), copy(buf, i, 1), iPosition);
end;
If iTmp = 2 then
break else
i := i + 1;
end;
// If (ilength <> 0) then
ilength := iPosition;
If pos('整', sStr) < 1 then
begin
if (pos('角', sStr) < 1) and (pos('分', sStr) < 1) then
sStr := sStr + '整';
end;
sStr :=stringreplace(sStr,'零零','零',[rfReplaceAll]);
sStr :=stringreplace(sStr,'零元','元',[rfReplaceAll]);
Result := Trim(sStr);
end;