function f_get_jedx(num : string):string;
//得到金额大写
function TForm_main.f_get_jedx(num : string):string;
//得到金额大写
var hz,money : array [0..20] of string;
rmb : boolean;
str,str_tmp,val,num2 : string;
i,il_i,lpos : integer;
begin
rmb := true;
if not rmb then
begin
hz[1]:='一';
hz[2]:='二';
hz[3]:='三';
hz[4]:='四';
hz[5]:='五';
hz[6]:='六';
hz[7]:='七';
hz[8]:='八';
hz[9]:='九';
hz[10]:='十';
hz[11]:='百';
hz[12]:='千';
hz[13]:='万';
hz[14]:='亿';
hz[15]:='点';
end
else
begin
hz[1]:='壹';
hz[2]:='贰';
hz[3]:='叁';
hz[4]:='肆';
hz[5]:='伍';
hz[6]:='陆';
hz[7]:='柒';
hz[8]:='捌';
hz[9]:='玖';
hz[10]:='拾';
hz[11]:='佰';
hz[12]:='仟';
hz[13]:='万';
hz[14]:='亿';
hz[15]:='元';
money[1]:='角';
money[2]:='分';
end;
val := num;
if pos('.',val) <> 0 then
begin
num := copy(val,1,pos('.',val)-1);
//整数
num2 := copy(val,pos('.',val)+1,10);
//小数
end;
str := '';
for i := 1 to length(num)do
begin
str_tmp := copy(num,i,1);
if str_tmp = '1' then
str := str + hz[1];
if str_tmp = '2' then
str := str + hz[2];
if str_tmp = '3' then
str := str + hz[3];
if str_tmp = '4' then
str := str + hz[4];
if str_tmp = '5' then
str := str + hz[5];
if str_tmp = '6' then
str := str + hz[6];
if str_tmp = '7' then
str := str + hz[7];
if str_tmp = '8' then
str := str + hz[8];
if str_tmp = '9' then
str := str + hz[9];
if str_tmp = '0' then
str := str + '';
if str_tmp='0' then
if (copy(str,length(str)-2,2)='零') or (str='') or (i=length(num)) then
str := str
else
str := str + '零'
else
case length(num) -i + 1 of
1 : str := str;
2,6,10 : str := str + hz[10];
3,7,11 : str := str + hz[11];
4,8,12 : str := str + hz[12];
//千
5,13 : str := str + hz[13];
//'万'
9 : str := str + '亿';
end;
if (length(num)-i+1=9) and (copy(num,length(num)-8,1)='0') then
begin
if copy(str,length(str)-2,2)='零' then
str := copy(str,1,length(str)-2);
str := str +'亿';
end;
if (length(num)-i+1=5) and (copy(num,length(num)-4,1)='0') then
begin
if copy(str,length(str)-2,2)='零' then
str := copy(str,1,length(str) - 2);
str := str +'万';
end;
end;
if copy(str,length(str)-2,2)='零' then
str := copy(str,1,length(str) - 2);
lpos := pos('亿万',str);
if lpos <> 0 then
str := copy(str,1,lpos+1)+copy(str,lpos+4,10000);
if pos('.',val)=0 then
if rmb then
f_get_jedx := str+hz[15]
else
f_get_jedx := str;
str := str + hz[15];
//点or 元
il_i := length(num2);
if rmb and (il_I>2) then
il_i := 2;
for i := 1 to il_ido
begin
str_tmp := copy(num2,i,1);
if str_tmp = '1' then
str := str + hz[1];
if str_tmp = '2' then
str := str + hz[2];
if str_tmp = '3' then
str := str + hz[3];
if str_tmp = '4' then
str := str + hz[4];
if str_tmp = '5' then
str := str + hz[5];
if str_tmp = '6' then
str := str + hz[6];
if str_tmp = '7' then
str := str + hz[7];
if str_tmp = '8' then
str := str + hz[8];
if str_tmp = '9' then
str := str + hz[9];
if str_tmp = '0' then
str := str + '零';
if rmb and (copy(str,length(str)-2,2)<>'零') then
str :=str + money;
end;
while copy(str,length(str),2) = '零'do
str := copy(str,1,length(str)-2);
//成对的零消成单个零
i := 3;
while i < length(str)do
begin
if copy(str,i,4) = '零零' then
str := copy(str,1,i-1) + copy(str,i+2,1000);
i := i + 2;
end;
//成对的零消成单个零
i := 3;
while i < length(str)do
begin
if copy(str,i,4) = '零零' then
str := copy(str,1,i-1) + copy(str,i+2,1000);
i := i + 2;
end;
//去掉元和万前面的零
i := 3;
while i < length(str)do
begin
if (copy(str,i,4)='零万') or (copy(str,i,4)='零元') then
str := copy(str,1,i-1) + copy(str,i+2,1000);
i := i + 2;
end;
//改拾零成拾
i := 3;
while i < length(str)do
begin
if (copy(str,i,4)='拾零') then
str := copy(str,1,i+1) + copy(str,i+4,1000);
i := i + 2;
end;
//改百零成拾
i := 3;
while i < length(str)do
begin
if (copy(str,i,4)='佰零') then
str := copy(str,1,i+1) + copy(str,i+4,1000);
i := i + 2;
end;
//改亿万成亿
i := 3;
while i < length(str)do
begin
if (copy(str,i,4)='亿万') then
str := copy(str,1,i+1) + copy(str,i+4,1000);
i := i + 2;
end;
//“元角”处理成“元”
i := 3;
while i < length(str)do
begin
if copy(str,i,4)='元角' then
str := copy(str,1,i+1) + copy(str,i+2,1000);
i := i + 2;
end;
f_get_jedx := str;
end;
//调用函数
edit1.Text := f_get_jedx('10234.56');