13,826
社区成员
发帖
与我相关
我的任务
分享
function toChineseCapitalMoney(const Num: Extended): String;
const
cNum: String = '零壹贰叁肆伍陆柒捌玖◆万仟佰拾亿仟佰拾万仟佰拾元角分';
cCha: String = '零仟零佰零拾零零零零零亿零万零元亿万零角零分零整◆零零零零零亿万元亿零整整';
var
sNum: String;
i: Integer;
begin
if (Num <> 0) and (abs(Num) < 10000000000000) Then
begin
sNum := FormatFloat('0', RoundTo(Num, -2) * 100.0);
for i := 1 to Length(sNum) do
Result := Result + Copy(cNum, StrToInt(Copy(sNum, i, 1)) + 1, 1) +
Copy(cNum, 26 - Length(sNum) + i, 1);
for i := 0 to 11 do
Result := StringReplace(Result, Copy(cCha, i * 2 + 1, 2),
Copy(cCha, i + 26, 1), [rfReplaceAll]);
if Num < 0 then
Result := '(负)' + Result;
end
else if Num = 0 then
Result := '零元'
else
Result := '溢出';
end;