一个实用的大小写金额转换程序
2008-03-08 12:52:07 来源:WEB开发网核心提示:AnsiString GetBigMoney(AnsiString s) { if ((s.Length()<=8) && (s.ToIntDef(0)==0)) return "币零元零角整"; AnsiString odxc,odxs,oszc,oscc,oscc0; int oi,oi0
AnsiString GetBigMoney(AnsiString s)
{
if ((s.Length()<=8) && (s.ToIntDef(0)==0)) return "币零元零角整";
AnsiString odxc,odxs,oszc,oscc,oscc0; int oi,oi0,i;
double ormb=StrToFloat(s); //金额小写
if (ormb==0.00) return "币零元零角整";
odxc="分角圆拾佰仟万拾佰仟亿拾佰仟万拾佰仟亿";
odxs="零壹贰叁肆伍陆柒捌玖";
oszc=FloatToStr(abs(ormb));
i=Ansipos('.',s);
oszc.Delete(i,1); // stuf(oszc,18,1,'');
oszc=Trim(oszc); oscc=""; oi0=0;
for (oi=oszc.Length();oi>0;oi--)
{ oscc=odxc.SubString(oi0*2+1,2)+oscc; oscc=odxs.SubString(StrToInt(oszc.SubString(oi,1))*2+1,2)+oscc;
oi0++; }
oscc0="";
for (oi=1;oi<=oscc.Length();oi=oi+4)
{ if (oscc.SubString(oi,2)=="零" )
{ if ( oscc.SubString(oi+2,2)=="万" )
{ if ( oscc0.SubString(oscc0.Length()-3,4)!="亿零" )
{ if (oscc0.SubString(oscc0.Length()-1,2)=="零" )
oscc0=oscc0.SubString(1,oscc0.Length()-2)+"万";
else oscc0=oscc0+"万"; }
continue; }
if ( oscc.SubString(oi+2,2)=="圆")
{
if (oscc0.SubString(oscc0.Length()-1,2)=="零")
oscc0=oscc0.SubString(1,oscc0.Length()-2)+"圆";
else oscc0=oscc0+"圆";
continue;
}
if ( oscc.SubString(oi+2,2)=="亿" )
{
if (oscc0.SubString(oscc0.Length()-1,2)=="零")
oscc0=oscc0.SubString(1,oscc0.Length()-2)+"亿";
else oscc0=oscc0+"亿";
continue; }
if (oscc0.SubString(oscc0.Length()-1,2)!="零" )
oscc0=oscc0+"零";
}
else oscc0=oscc0+oscc.SubString(oi,4);
}
if ((oscc0.SubString(oscc0.Length()-3,4)=="圆零") )
{ oscc0=oscc0.SubString(1,oscc0.Length()-2)+"整";
return "币"+oscc0; }
if ((oscc0.SubString(oscc0.Length()-3,4)=="角零" ))
{ oscc0=oscc0.SubString(1,oscc0.Length()-2)+"整";
return "币"+oscc0;
}
if ((oscc0.SubString(oscc0.Length()-1,2)=="零" ))
oscc0=oscc0.SubString(1,oscc0.Length()-2)+"圆整";
return "币"+oscc0;
}
[]
更多精彩
赞助商链接