我这有个,直接用就是了。呵呵。 function number_to_china(number:string):string; var a,Fs,dx,d2,zs,xs,h,jg:string; i,ws,l,w,j,lx:integer; begin number := Trim(number); if copy(number,1,1)='-' then begin Delete(number,1,1);fs:='负';end else fs:=''; dx:='零壹贰叁肆伍陆柒捌玖'; d2:='拾佰仟万亿'; i := AnsiPos('.',number); //小数点位置 If i = 0 Then zs := number //整数 Else begin zs:=copy(number,1,i - 1); //整数部分 xs:=copy(number,i + 1,2); End; ws:= 0; l := 0; For i := Length(zs) downTo 1 do begin ws := ws + 1; h := ''; w:=strtoint(copy(zs, i, 1)); if (w=0) and (i=1) then jg:='零'; If w > 0 Then Case ws of 2..5:h:=copy(d2,(ws-1)*2-1,2); 6..8: begin h:=copy(d2,(ws-5)*2-1,2); If AnsiPos('万',jg)=0 Then h:=h+'万'; end; 9:h:=copy(d2,(ws-4)*2-1,2); 10..13:h := copy(d2,(ws-9)*2-1, 2); End; jg:=copy(dx,(w+1)*2-1,2) + h + jg; end; j:=AnsiPos('零零',jg); While j > 0 do begin jg := copy(jg, 1, j - 1) + copy(jg, j + 2,2); j := AnsiPos('零零',jg); end; If (Length(jg) > 1) And (copy(jg,length(jg)-1,2)='零') Then jg :=copy(jg,1,Length(jg)-2); j := AnsiPos('零亿',jg); If j > 0 Then jg := copy(jg,1, j - 1) + copy(jg, j + 2,2); //转换小数部分 lx := Length(xs); If lx > 0 Then begin jg := jg + '元'; For i := 1 To lx do begin case i of 1:a:='角'; 2:a:='分'; end; jg := jg + copy(dx, strtoint(copy(xs,i,1))*2 + 1, 2)+a; end; End; result := fs+jg; end;
function number_to_china(number:string):string;
var a,Fs,dx,d2,zs,xs,h,jg:string;
i,ws,l,w,j,lx:integer;
begin
number := Trim(number);
if copy(number,1,1)='-' then begin
Delete(number,1,1);fs:='负';end
else fs:=''; dx:='零壹贰叁肆伍陆柒捌玖';
d2:='拾佰仟万亿';
i := AnsiPos('.',number); //小数点位置
If i = 0 Then
zs := number //整数
Else begin
zs:=copy(number,1,i - 1); //整数部分
xs:=copy(number,i + 1,2);
End;
ws:= 0; l := 0;
For i := Length(zs) downTo 1 do begin
ws := ws + 1; h := '';
w:=strtoint(copy(zs, i, 1));
if (w=0) and (i=1) then jg:='零';
If w > 0 Then
Case ws of
2..5:h:=copy(d2,(ws-1)*2-1,2);
6..8:
begin
h:=copy(d2,(ws-5)*2-1,2);
If AnsiPos('万',jg)=0 Then h:=h+'万';
end;
9:h:=copy(d2,(ws-4)*2-1,2);
10..13:h := copy(d2,(ws-9)*2-1, 2);
End;
jg:=copy(dx,(w+1)*2-1,2) + h + jg;
end;
j:=AnsiPos('零零',jg);
While j > 0 do begin
jg := copy(jg, 1, j - 1) + copy(jg, j + 2,2);
j := AnsiPos('零零',jg);
end;
If (Length(jg) > 1) And (copy(jg,length(jg)-1,2)='零') Then jg :=copy(jg,1,Length(jg)-2);
j := AnsiPos('零亿',jg);
If j > 0 Then jg := copy(jg,1, j - 1) + copy(jg, j + 2,2);
//转换小数部分
lx := Length(xs);
If lx > 0 Then
begin
jg := jg + '元';
For i := 1 To lx do
begin
case i of
1:a:='角';
2:a:='分';
end;
jg := jg + copy(dx, strtoint(copy(xs,i,1))*2 + 1, 2)+a;
end;
End;
result := fs+jg;
end;