function chn_money(money: double): string;
var
intpart, chiao, cent: integer;
fracpart: double;
signstr, tstr: string;
begin
signstr:='';
if (money<0) then
begin
money:=-money;
signstr:='负';
end;
money:=money+0.005; //包含四舍五入
intpart:=Trunc(money); //Trunc truncates a real number to an integer.
fracpart:=money-intpart;
fracpart:=fracpart*10;
chiao:=Trunc(fracpart);
fracpart:=fracpart-chiao;
fracpart:=fracpart*10;
cent:=Trunc(fracpart);
tstr:=chn_intvalue(intpart);
if (chiao=0) and (cent=0) then
result:=tstr+'元整';
if (chiao <> 0) and (cent = 0) then
result:=tstr+'元'+chn_number[chiao]+'角整';
if (chiao=0) and (cent <> 0) then
result:=tstr+'元'+'零'+chn_number[cent]+'分';
if (chiao <> 0) and (cent <> 0) then
result:=tstr+'元'+chn_number[chiao]+'角'+chn_number[cent]+'分';
result:=signstr+result;
end;
决定的正确
//----------------------- function SmallToBig----------------------------
// 小写转化为大写
//-----------------------------------------------------------------------
function SmallTOBig(small:real):string;
var
SmallMonth,BigMonth,wei,shu,BigMonth1:string;
wei1,qianwei1:string[2];
qianwei,dianweizhi,qian:integer;
havezero:Boolean;
begin
wei:='';
shu:='';
BigMonth1:='';
qianwei:=-2;
Smallmonth:=formatfloat('0.00',small);
dianweizhi :=pos('.',Smallmonth);{小数点的位置}
{循环小写货币的每一位,从小写的右边位置到左边}
for qian:=length(Smallmonth) downto 1 do
begin
{如果读到的不是小数点就继续}
if qian<>dianweizhi then
begin
{位置上的数转换成大写}
case strtoint(copy(Smallmonth,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);
BigMonth :=wei1+qianwei1+BigMonth;{组合成大写金额}
shu:=wei1+shu;
wei:=qianwei1+wei;
end;
end;
havezero:=False;
{去掉多余零}
//showmessage(shu+wei);
for qian:=1 to ((length(shu) div 2)-2) do
begin
if (copy(shu,2*qian-1,2)='零') and ((copy(wei,2*qian-1,2)='万') or (copy(wei,2*qian-1,2)='元') or (copy(wei,2*qian-1,2)='亿'))then
begin
havezero:=False;
BigMonth1:=BigMonth1+copy(wei,2*qian-1,2);
end
else if (copy(shu,2*qian-1,2)='零') and not ((copy(wei,2*qian-1,2)='万') or (copy(wei,2*qian-1,2)='元') or (copy(wei,2*qian-1,2)='亿'))then
havezero:=True
else
begin
if havezero then
begin
BigMonth1:=BigMonth1+'零'+copy(shu,2*qian-1,2)+copy(wei,2*qian-1,2);
havezero:=False;
end
else
BigMonth1:=BigMonth1+copy(shu,2*qian-1,2)+copy(wei,2*qian-1,2);
end;
end;
qian:=(length(shu) div 2)-2;
if (copy(shu,2*qian+1,2)='零') and (copy(shu,2*qian+3,2)='零') then
BigMonth1:=BigMonth1+'整';
if (copy(shu,2*qian+1,2)='零') and (copy(shu,2*qian+3,2)<>'零') then
BigMonth1:=BigMonth1+'零'+copy(shu,2*qian+3,2)+copy(wei,2*qian+3,2);
if (copy(shu,2*qian+1,2)<>'零') and (copy(shu,2*qian+3,2)='零') then
BigMonth1:=BigMonth1+copy(shu,2*qian+1,2)+copy(wei,2*qian+1,2)+'整';
if (copy(shu,2*qian+1,2)<>'零') and (copy(shu,2*qian+3,2)<>'零') then
BigMonth1:=BigMonth1+copy(shu,2*qian+1,2)+copy(wei,2*qian+1,2)+copy(shu,2*qian+3,2)+copy(wei,2*qian+3,2);
//SmallTOBig:=BigMonth;
SmallTOBig:=BigMonth1;
end;
function tmainform.RMB(NN:real):string;
var
HZ,NS,NW,NA,N1,N2:string;
LA,X,Nk:integer;
begin
if NN>9999999999999.99 then
begin
MessageDlg('金额溢出.',mtError,[mbOk], 0);
HZ:='';
Result:=HZ;
exit;
end;
if NN=0 then
begin
HZ:='零元';
result:=HZ;
exit;
end;
NS:='零壹贰叁肆伍陆柒捌玖';
NW:='分角元拾佰仟万拾佰仟亿拾佰仟万';
NA:=FloatToStr(NN*100);
LA:=length(NA);
X:=1;
HZ:='';
while X<=LA do
begin
NK:=Ord(NA[x])-Ord('0');
N1:=Copy(NS,NK*2+1,2);
N2:=Copy(NW,LA*2+1-X*2,2);
if (NK=0) AND ((N2='亿') OR( N2='万') OR( N2='元'))then
begin
if copy(HZ,Length(HZ)-1,2)='零' then
HZ:=copy(HZ,1,length(HZ)-2);
if copy(HZ,Length(HZ)-1,2)='亿' then
if N2='元' then
begin
N1:=N2;
N2:='零';
end
else
N2:=''
else
begin
N1:=N2;
N2:='零';
end
end
else if NK=0 then
begin
if copy(HZ,length(HZ)-1,2)='零' then
N1:='';
if N2='分' then
begin
if copy(HZ,length(HZ)-1,2)='零' then
HZ:=copy(HZ,1,length(HZ)-2)+'整'
else
HZ:=HZ+'整';
N1:='';
end;
N2:='';
end;
HZ:=HZ+N1+N2;
X:=X+1
end;
Result:=HZ;
end;