我的程序:
type
TMoneyKinds=(isSTAND, isSHORT, isLONG);
function ChangeMoney(Const InMoney: double; Const InKind: TMoneyKinds): string;
const
UNITAGE_STR : String = '分角元拾佰仟万拾佰仟亿拾佰仟'; // 单位大写中文字符串
// '分角元拾佰仟万拾佰仟亿拾佰仟' '仟佰拾亿仟佰拾万仟佰拾元角分'
UPPER_STR : String = '零壹贰叁肆伍陆柒捌玖'; // 数值大写中文字符串
ZERO_STR : String = '零';
var
LowString: string; //小写金额字符串
HighString: string; //大写金额字符串
LabelString: string; //符号位
MidString, BzString: string;
StrLeng: integer;
Loop1, Num1,Num2: integer;
begin
LabelString:='';
HighString:='';
if InMoney<>0
then begin
if InMoney<0 then LabelString:='负';
LowString:=Trim(Format('%15.2f',[ABS(InMoney)]));
StrLeng:=Length(LowString);
LowString:=Copy(LowString,1,StrLeng-3)+Copy(LowString,Strleng-1,2); //去掉小数点
StrLeng:=Strleng-1;
MidString:='';
BzString:='';
for Loop1:=StrLeng downto 1
do begin
num1:=StrToInt(Copy(LowString,Loop1,1));
Num2:=StrLeng-Loop1+1;
case InKind of
isSHORT: HighString:=Copy(UPPER_STR,2*Num1+1,2)+HighString;
isLONG: HighString:=Copy(UPPER_STR,2*Num1+1,2)
+Copy(UNITAGE_STR,Num2*2-1,2)+HighString;
else begin // "isSTAND"
case Num2 of
1: begin
if Num1=0
then BzString:=ZERO_STR
else HighString:=Copy(UPPER_STR,2*Num1+1,2)
+Copy(UNITAGE_STR,Num2*2-1,2);
end; {1}
2: begin
if Num1=0
then begin
if BzString=ZERO_STR
then HighString:='整'
else HighString:='零'+HighString;
end
else HighString:=Copy(UPPER_STR,2*Num1+1,2)
+Copy(UNITAGE_STR,Num2*2-1,2)+HighString;
BzString:='';
end; {2}
3: begin
HighString:=Copy(UNITAGE_STR,Num2*2-1,2)+HighString;
if Num1=0
then BzString:=ZERO_STR
else begin
HighString:=Copy(UPPER_STR,2*Num1+1,2)+HighString;
BzString:='';
end;
end; {3}
7: begin
if Num1=0
then begin
if BzString<>ZERO_STR
then begin
BzString:=ZERO_STR;
HighString:=ZERO_STR+HighString;
end;
if (StrLeng>=11) and (copy(LowString,Loop1-3,4)<>'0000')
then HighString:=Copy(UNITAGE_STR,Num2*2-1,2)+HighString;
end
else begin
HighString:=Copy(UPPER_STR,2*Num1+1,2)
+Copy(UNITAGE_STR,Num2*2-1,2)+HighString;
BzString:='';
end;
end; {7}
11: begin
if Num1=0
then begin
if BzString<>ZERO_STR
then begin
BzString:=ZERO_STR;
HighString:=ZERO_STR+HighString;
end;
HighString:=Copy(UNITAGE_STR,Num2*2-1,2)+HighString;
end
else begin
HighString:=Copy(UPPER_STR,2*Num1+1,2)
+Copy(UNITAGE_STR,Num2*2-1,2)+HighString;
BzString:='';
end;
end; {11}
4,5,6,8,9,10,12,13,14: begin
if Num1=0
then begin
if BzString<>ZERO_STR
then begin
BzString:=ZERO_STR;
HighString:=ZERO_STR+HighString;
end;
end
else begin
BzString:='';
HighString:=Copy(UPPER_STR,2*Num1+1,2)
+Copy(UNITAGE_STR,Num2*2-1,2)+HighString;
end;
end; {4,5,6,8,9,10,12,13,14}
end; {case Num2 of}
end; {isSTAND}
end; {case InKind of}
end; {for Loop1:=StrLeng to 1}
end; {if InMoney<>0}
Result:=LabelString+HighString;
end;