function SmallTOBig(small:real):string;
var
SmallMoney,BigMoney:string;
wei1,qianwei1:string[2];
qianwei,dianweizhi,qian:integer;
begin
qianwei:=-2;
Smallmoney:=formatfloat('0.00',small);
dianweizhi:=pos('.',Smallmoney);
for qian:=length(Smallmoney) downto 1 do
begin
if qian<>dianweizhi then
begin
case strtoint(copy(Smallmoney,qian,1)) of
1:wei1:='壹'; 2:wei1:='贰';
3:wei1:='叁'; 4:wei1:='肆';
5:wei1:='伍'; 6:wei1:='陆';
7:wei1:='柒'; 8:wei1:='捌';
9:wei1:='玖'; 0:wei1:='零';
end;
case qianwei of
-3:qianwei1:='厘';
-2:qianwei1:='分';
-1:qianwei1:='角';
0 :qianwei1:='圆';
1 :qianwei1:='拾';
2 :qianwei1:='佰';
3 :qianwei1:='千';
4 :qianwei1:='万';
5 :qianwei1:='拾';
6 :qianwei1:='佰';
7 :qianwei1:='千';
8 :qianwei1:='亿';
9 :qianwei1:='十';
10:qianwei1:='佰';
11:qianwei1:='千';
end;
inc(qianwei);
Bigmoney :=wei1+qianwei1+Bigmoney;
end;
end;
SmallTOBig:=Bigmoney;
end;
var
SmallMoney,BigMoney:string;
wei1,qianwei1:string[2];
qianwei,dianweizhi,qian:integer;
begin
qianwei:=-2;
Smallmoney:=formatfloat('0.00',small);
dianweizhi:=pos('.',Smallmoney);
for qian:=length(Smallmoney) downto 1 do
begin
if qian<>dianweizhi then
begin
case strtoint(copy(Smallmoney,qian,1)) of
1:wei1:='壹'; 2:wei1:='贰';
3:wei1:='叁'; 4:wei1:='肆';
5:wei1:='伍'; 6:wei1:='陆';
7:wei1:='柒'; 8:wei1:='捌';
9:wei1:='玖'; 0:wei1:='零';
end;
case qianwei of
-3:qianwei1:='厘';
-2:qianwei1:='分';
-1:qianwei1:='角';
0 :qianwei1:='圆';
1 :qianwei1:='拾';
2 :qianwei1:='佰';
3 :qianwei1:='千';
4 :qianwei1:='万';
5 :qianwei1:='拾';
6 :qianwei1:='佰';
7 :qianwei1:='千';
8 :qianwei1:='亿';
9 :qianwei1:='十';
10:qianwei1:='佰';
11:qianwei1:='千';
end;
inc(qianwei);
Bigmoney :=wei1+qianwei1+Bigmoney;
end;
end;
SmallTOBig:=Bigmoney;
end;
function TForm1.xTOd(i:Real):string;
const
d='零壹贰叁肆伍陆柒捌玖分角元拾佰仟万拾佰仟亿';
var
m,k:string;
j:integer;
begin
k:='';
m:=floattostr(int(i*100));
for j:=length(m) downto 1 do
k:=k+d[(strtoint(m[Length(m)-j+1])+1)*2-1]+
d[(strtoint(m[Length(m)-j+1])+1)*2]+d[(10+j)*2-1]+d[(10+j)*2];
xTOd:=k;
end; 调用:
procedure TForm1.Button1Click(Sender: TObject);
var
Sum:real;
begin
sum:=12.34;
showmessage('人民币大写:'+xTOd(Sum));
end;
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;
end;
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;
Result:=lTemp+rTemp+'整';
end;