我的问题解决了,下面是我的程序!
有类似问题的朋友可以参考,也谢谢上面几位朋友!
dict_1[1] := 'one';
dict_1[2] := 'two';
dict_1[3] := 'three';
dict_1[4] := 'four';
dict_1[5] := 'five';
dict_1[6] := 'six';
dict_1[7] := 'seven';
dict_1[8] := 'eight';
dict_1[9] := 'nine';
dict_1[10] := 'ten';
dict_1[11] := 'eleven';
dict_1[12] := 'twelve';
dict_1[13] := 'thirteen';
dict_1[14] := 'fourteen';
dict_1[15] := 'fifteen';
dict_1[16] := 'sixteen';
dict_1[17] := 'seventeen';
dict_1[18] := 'eighteen';
dict_1[19] := 'nineteen';
dict_1[20] := 'twenty';
dict_1[30] := 'thirty';
dict_1[40] := 'fourty';
dict_1[50] := 'fifty';
dict_1[60] := 'sixty';
dict_1[70] := 'seventy';
dict_1[80] := 'eighty';
dict_1[90] := 'ninety';
procedure Tfrm_main.Button7Click(Sender: TObject);
var
inparm,outparm,s1,s2,s3,inpoint:string
nlengh,nn,mm,plengh,i:integer;
dl_2,dl_1: real;
//dd,dd1:widestring;
begin
if trim(price1.text)='' then exit;
dl_1:=int(strtofloat(trim(price1.text)));
dl_2:=Frac(strtofloat(trim(price1.text)));
inparm := floattostr(dl_1);
nlengh := length(inparm);
inpoint := floattostr(dl_2);
outparm:=cl_int(inparm);
if inpoint <> '0.00' then
begin
if strtofloat(inparm) <> 0 then
outparm := outparm + ' point'
else
outparm := outparm + 'zero point';
inpoint := copy(inpoint,3,length(inpoint));
for i := 1 to length(inpoint) do
begin
nn := strtoint(copy(inpoint,i,1));
if nn = 0 then
if i<>length(inpoint) then
outparm :=outparm + ' zero'
else
outparm :=outparm
else
outparm :=outparm + ' ' +dict_1[nn];
end;
say_total.text:=outparm;
end;
end;
function Tfrm_main.cl_int(str:string):string;
var
inparm,outparm,s1,s2,s3,inpoint:string
nlengh,nn,mm,plengh,i:integer;
dl_2,dl_1: real;
begin
//转换整数部分
inparm:=str;
nlengh:=length(inparm);
case nlengh of
1:
begin
nn := strtoint(inparm);
if nn <> 0 then
outparm := dict_1[nn]
else
outparm :='';
end;
2:begin
nn := strtoint(inparm);
mm := nn mod 10;
if (mm = 0) or (copy(inparm,1,1) = '1') then
outparm := dict_1[nn]
else
begin
s1 := copy(inparm,1,1);
s2 := copy(inparm,2,1);
s1 := floattostr(strtofloat(s1) * 10 );
outparm := cl_int(s1) + '-' + cl_int(s2);
end;
end
3:begin
s1 := copy(inparm,1,1);
s2 := copy(inparm,2,2);
if s2 <> '00' then
outparm := cl_int(s1) + ' hundred and ' + cl_int(s2)
else
outparm := cl_int(s1) + ' hundred ' + cl_int(s2);
end;
4:begin
s1 := copy(inparm,1,1);
s2 := copy(inparm,2,3);
outparm := cl_int(s1) + ' thousand ' + cl_int(s2);
end;
5:begin
s1 := copy(inparm,1,2);
s2 := copy(inparm,3,3);
outparm := cl_int(s1) + ' thousand ' + cl_int(s2);
end;
6:begin
s1 := copy(inparm,1,3);
s2 := copy(inparm,4,3);
outparm := cl_int(s1) + ' thousand ' + cl_int(s2);
end;
7:begin
s1 := copy(inparm,1,1);
s2 := copy(inparm,2,6);
outparm := cl_int(s1) + ' million ' + cl_int(s2);
end;
8:begin
s1 := copy(inparm,1,2);
s2 := copy(inparm,3,6);
outparm := cl_int(s1) + ' million ' + cl_int(s2);
end;
9:begin
s1 := copy(inparm,1,3);
s2 := copy(inparm,4,6);
outparm := cl_int(s1) + ' million ' + cl_int(s2);
end;
end;
cl_int:=outparm;
end;