数据源为87.80,合并生成的文档如何得到捌拾柒元捌角正
- 提问者网友:难遇难求
- 2021-05-04 21:53
- 五星知识达人网友:平生事
- 2021-05-04 22:01
我这里有一个DELPHI转换源码,不知道是不是你需要的。也许能帮上你。
函数原型:
function ToBigRMB(RMB: string): string;
const
BigNumber='零壹贰叁肆伍陆柒捌玖';
BigUnit='万仟佰拾亿仟佰拾万仟佰拾元';
{共可表示13为金额}
var nLeft, nRigth, lTemp, rTemp, BigNumber1, BigUnit1: string;
I: Integer;
begin
{取整数和小数部分}
RMB:=FormatCurr('0.00', StrToFloat(RMB));
nLeft:=copy(RMB, 1, Pos('.', RMB) - 1);
nRigth:=copy(RMB, Pos('.', RMB) + 1, 2);
for I:=1 to Length(nLeft) do
begin
BigNumber1:=copy(BigNumber, StrToInt(nLeft[I]) * 2 + 1, 2);
BigUnit1:=copy(BigUnit, (Trunc(Length(BigUnit) / 2) - Length(nleft) + I - 1) * 2 + 1, 2);
if (BigNumber1='零') and ((copy(lTemp, Length(lTemp)- 1, 2))='零') then
lTemp:=copy(lTemp, 1, Length(lTemp) - 2);
if (BigNumber1='零') and ((BigUnit1='亿') or (BigUnit1='万') or (BigUnit1='元')) then
begin
BigNumber1:=BigUnit1;
if BigUnit1<>'元' then
BigUnit1:='零'
else
BigUnit1:='';
end;
if (BigNumber1='零') and (BigUnit1<>'亿') and (BigUnit1<>'万') and (BigUnit1<>'元') then
BigUnit1:='';
lTemp:=lTemp + BigNumber1 + BigUnit1;
if Pos('亿万', lTemp)<>0 then
Delete(lTemp, Pos('亿万', lTemp) + 2, 2);
{转换小数部分}
if StrToInt(nRigth[1])<>0 then
rTemp:=copy(BigNumber, StrToInt(nRigth[1]) * 2 + 1, 2) + '角';
if StrToInt(nRigth[2])<>0 then
begin
if StrToInt(nRigth[1])=0 then
rTemp:='零';
rTemp:=rTemp + copy(BigNumber, StrToInt(nRigth[2]) * 2 + 1, 2) + '分';
end;
end;
Result:=lTemp + rTemp + '整';
end;