AZero := False ;
AUpperNum := '' ;
AMoneyUnit := '' ;
result := '';
if NumBer < 0 then
begin
result := '负' ;
N := - NumBer ;
end
else
N := NumBer ;
Str(N:16:2,StrNumber);
for I := 1 to 16 do
begin
if StrNumber[I] <> ' ' then
begin
AMoneyUnit := MoneyUnit[I];
if StrNumber[I] = '0' then
begin
if AZero and (copy(result,Length(result)-1,2)='零') then
result := copy(result,1,Length(result)-2);
case I of
1..4,6..8,10..12:begin // 万,仟,佰,拾
AUpperNum := '零' ;
AMoneyUnit := '' ;
end;
5,9,13: begin // 亿,万,元
if StrToFloat(StrNumber) < 1 then AMoneyUnit := '' ;
AUpperNum := '' ;
end;
15: begin // 角
if StrToFloat(StrNumber) < 1 then AUpperNum := ''
else AUpperNum := '零' ;
AMoneyUnit := '' ;
end;
16: begin // 分
AUpperNum := '' ;
AMoneyUnit := '' ;
end;
end;
AZero := True ;
end
else
begin
if StrNumber[I] = '.' then
begin
AUpperNum := '';
AMoneyUnit := '';
end
else
begin
AZero := False ;
AUpperNum := UpperNum[StrToInt(StrNumber[I])];
end
end;
result := result + (AUpperNum + AMoneyUnit)
end;
end;
result := result + '整' ;
end;
Function szzf(num:Double):String;
const
szd:string = '零壹贰叁肆伍陆柒捌玖';
dwd:string = '分角元拾佰仟万拾佰仟亿拾佰仟';
kdwd:string = '零仟零佰零拾零角零分';
var
n1,n2,nm:shortint;
je,zf:string;
getastr:string[4];//用于临时保存一个字符
code,getanum:integer;
begin
//检测数据范围 最大999999999999.99 最小0.00
If (num > 999999999999.99) Or (num = 0) Or (num < 0.01) Then
begin
szzf := '';
Exit;
End;
je:= '';
//将数字从右到左读成大写金额
str(num:15:2,zf); //将数字转换“#####.##”格式的字符格式
zf:=trim(zf);
n1 := Length(zf); //数字长度
n2 := 1;
For nm := 1 To n1 do
begin
//getastr:=;
If copy(zf,n1,1)<> '.' Then //跳过小数点
begin
getastr:=copy(zf, n1, 1);
val(getastr,getanum,code);
getastr:=copy(szd, (getanum+1)*2 - 1, 2);
je := getastr+copy(dwd, n2*2 - 1, 2)+ je;
n2 := n2 + 1;
end;
n1 := n1 - 1;
end;
//去掉大写金额中不符合使用习惯的部分
n1:= Length(je); //字符串长度
for nm:=1 to (n1 div 4)-1 do
begin
n2:=n1-nm*4+1;
getastr:=copy(je,n2,n2+4);
if AnsiPos(getastr,kdwd)<>0 then
je:=copy(je,1,n1-nm*4+2)+copy(je,n1-nm*4+5,length(je));
end;
n1:=AnsiPos('零零',je);
while n1<>0 do
begin
je:=copy(je,1,n1+1)+copy(je,n1+4,length(je));
n1:=AnsiPos('零零',je);
end;
//当出现“零亿”,“零万”,“零元”时去掉“零”
n1:=AnsiPos('零亿',je);
if n1<>0 then
je:=copy(je,1,n1-1)+copy(je,n1+2,length(je));
n1:=AnsiPos('零万',je);
if n1<>0 then
je:=copy(je,1,n1-1)+copy(je,n1+2,length(je));
n1:=AnsiPos('零元',je);
if n1<>0 then
je:=copy(je,1,n1-1)+copy(je,n1+2,length(je));
//处理最后出现的“零”
n1:=length(je);
If copy(je,n1-1,n1)='零' Then je:=copy(je,1,n1-2);
n1:=length(je);
getastr:=copy(je,n1-1,2);
If getastr='元'//如果没小数部分则加“整“
Then je:=je+'整'
else
if (getastr<>'分') and (getastr<>'角') then je:=je+'元整';
szzf:= je;
End;