货币小写与大写如何转换?

时间:2022-03-12 09:12:40
大家好:
   最近有这样一个问题:
    货币小写与大写如何转换?如234要转化成贰百叁拾肆圆.
   请各位高手多多帮忙呀!!!!!!

6 个解决方案

#1


//请参考
http://kingron.myetang.com/zsfunc0e.htm

#2


编写函数:
Function  TFormFhdCw.XxToDx(const hjnum:real):String;
var Vstr,zzz,cc,cc1,Presult:string;
    xxbb:array[1..12]of string;
    uppna:array[0..9] of string;
    iCount,iZero,vPoint,vdtlno:integer;
begin
  //*设置大写中文数字和相应单位数组*//
  xxbb[1]:='亿';
  xxbb[2]:='仟';
  xxbb[3]:='佰';
  xxbb[4]:='拾';
  xxbb[5]:='万';
  xxbb[6]:='仟';
  xxbb[7]:='佰';
  xxbb[8]:='拾';
  xxbb[9]:='元';
  xxbb[10]:='.';
  xxbb[11]:='角';
  xxbb[12]:='分';
  uppna[0]:='零';
  uppna[1]:='壹';
  uppna[2]:='贰';
  uppna[3]:='叁';
  uppna[4]:='肆';
  uppna[5]:='伍';
  uppna[6]:='陆';
  uppna[7]:='柒';
  uppna[8]:='捌';
  uppna[9]:='玖';
  Str(hjnum:12:2,Vstr);
  cc:='';
  cc1:='';
  zzz:='';
  result:='';
  presult:='';
  iZero:=0;
  vPoint:=0;
  for iCount:=1 to 10 do
    begin
      cc:=Vstr[iCount];
      if cc<>' ' then
        begin
          zzz:=xxbb[iCount];
          if cc='0' then
          begin
            if iZero<1 then  //*对“零”进行判断*//
               cc:='零'
            else
               cc:='';
            if iCount=5 then     //*对万位“零”的处理*//
               if copy(result,length(result)-1,2)='零' then
                  result:=copy(result,1,length(result)-2)+xxbb[iCount]
+'零'
               else
                  result:=result+xxbb[iCount];
            cc1:=cc;
            zzz:='';
            iZero:=iZero+1;
          end
          else
            begin
              if cc='.' then
                begin
                  cc:='';
                  if (cc1='') or (cc1='零')  then
                  begin
                     Presult:=copy(result,1,Length(result)-2);
                     result:=Presult;
                     iZero:=15;
                  end;
                  if iZero>=1 then
                     zzz:=xxbb[9]
                  else
                     zzz:='';
                  vPoint:=1;
                end
              else
                begin
                  iZero:=0;
                  cc:=uppna[StrToInt(cc)];
                end
            end;
          result:=result+(cc+zzz)
        end;
    end;
    If Vstr[11]='0' then   //*对小数点后两位进行处理*//
    begin
       if Vstr[12]<>'0' then
       begin
          cc:='零';
          result:=result+cc;
          cc:=uppna[StrToInt(Vstr[12])];
          result:=result+(uppna[0]+cc+xxbb[12]);
       end
    end
    else
    begin
       if iZero=15 then
       begin
          cc:='零';
          result:=result+cc;
       end;
       cc:=uppna[StrToInt(Vstr[11])];
       result:=result+(cc+xxbb[11]);
       if Vstr[12]<>'0' then
       begin
          cc:=uppna[StrToInt(Vstr[12])];
          result:=result+(cc+xxbb[12]);
       end;
    end;
  result:=result+'正';
end;
请试试

#3


用下面的函数吧,我们很费劲才弄出来的!
              (另外  http://zhangxzh.diy.163.com免费的优秀报表控件!)

function SmallTOBig(small:real):string;
var
   S1,B1,w1,qw1:string;
   qw,dwz,q:integer;
begin
  s1:=formatfloat('0.00',small);  //格式化字符串
  dwz:=pos('.',s1);               //求小数点位置
  qw:=dwz-2;                      //第一位的位值
  for q:=1 to length(s1) do       //从第一位开始循环到最后一位
    begin
    if q<>dwz then                //是点位值跳过
       begin
         case strtoint(copy(S1,q,1)) of
         1:w1:='壹'; 2:w1:='贰';
         3:w1:='叁'; 4:w1:='肆';
         5:w1:='伍'; 6:w1:='陆';
         7:w1:='柒'; 8:w1:='捌';
         9:w1:='玖'; 0:w1:='零';
         end;
         case qw of
         -2:qw1:='分';  -1:qw1:='角';  0 :qw1:='元';
         1 :qw1:='拾';  2 :qw1:='佰';  3 :qw1:='仟';
         4 :qw1:='万';  5 :qw1:='拾';  6 :qw1:='佰';
         7 :qw1:='仟';  8 :qw1:='亿';  9 :qw1:='拾';
         10:qw1:='佰';  11:qw1:='仟';
         end;
         if w1='零' then             //数值是零的情况
            begin
            if (qw=4)or(qw=8) then   //数位是万位和亿位的情况
               begin
               if  ((q+1)<=length(s1))and((q+1)<>dwz) then
                   if (strtoint(copy(S1,q+1,1))<>0) then
                      b1:=b1+qw1+w1
                      else
                      begin
                      if copy(b1,length(b1)-1,2)<>'亿' then b1:=b1+qw1;
                      end;
               end;
            if qw=0 then b1:=b1+qw1;  //数位是个位的情况
            if (qw<>0)and(qw<>4)and(qw<>8) then  //数位不是万位,亿位,个位的情况
               if  ((q+1)<=length(s1))and((q+1)<>dwz) then
                   if (strtoint(copy(S1,q+1,1))<>0) then
                      B1 :=B1+w1;
            end
            else
            begin
            b1:=b1+w1+qw1;            //减位数
            end;
         dec(qw);
       end;
    end;
  SmallTOBig:=B1;
end;

#4


function getdaxie(value:Double): string;
var
    str2,str3,str4,returnje:widestring;
    int1:integer;
    function getme(v1:integer):widestring;
    var
        str1:widestring;
    begin
        str1:='零壹贰叁肆伍陆柒捌玖';
        Result:=Copy(str1,v1+1,1);
    end;
begin
    str2:=FormatFloat('0.00',value);
    str3:=Copy(str2,1,Pos('.',str2)-1);
    str4:=Copy(str2,Pos('.',str2)+1,length(str2)-Pos('.',str2));
    returnje:='';
    returnje:=getme(StrToInt(Copy(str4,2,1)))+returnje+'分';
    returnje:=getme(strToInt(Copy(str4,1,1)))+'角'+returnje;

    if Length(str3)>0 then
    begin
        int1:=StrToInt(Copy(str3,Length(str3),1));
        if int1=0 then
        begin
            if Length(str3)>1 then
                returnje:='元'+returnje
            else
                returnje:=getme(int1)+'元'+returnje;
        end
        else
            returnje:=getme(int1)+'元'+returnje;
    end;
    if Length(str3)>1 then
    begin
        int1:=StrToInt(Copy(str3,Length(str3)-1,1));
        if int1=0 then
        begin
            if StrToInt(Copy(str3,Length(str3),1))<>0 then
                returnje:=getme(int1)+returnje;
        end
        else
            returnje:=getme(int1)+'拾'+returnje;
    end;
    if Length(str3)>2 then
    begin
        int1:=StrToInt(Copy(str3,Length(str3)-2,1));
        if int1=0 then
        begin
            if StrToInt(Copy(str3,Length(str3)-1,1))<>0 then
                returnje:=getme(int1)+returnje;
        end
        else
            returnje:=getme(int1)+'佰'+returnje;
    end;
    if Length(str3)>3 then
    begin
        int1:=StrToInt(Copy(str3,Length(str3)-3,1));
        if int1=0 then
        begin
            if StrToInt(Copy(str3,Length(str3)-2,1))<>0 then
                returnje:=getme(int1)+returnje;
        end
        else
            returnje:=getme(int1)+'仟'+returnje;
    end;
    if Length(str3)>4 then
    begin
        int1:=StrToInt(Copy(str3,Length(str3)-4,1));
        if int1=0 then
            returnje:='万'+returnje
        else
            returnje:=getme(int1)+'万'+returnje;
    end;
    if Length(str3)>5 then
    begin
        int1:=StrToInt(Copy(str3,Length(str3)-5,1));
        returnje:=getme(int1)+'拾'+returnje;
    end;

    Result:=returnje;
end;

#5


哎,,都是这个问题。。

#6


http://qianfeng.diy.163.com/Num2RMB.zip
有个dll和使用说明,直接使用,无需重复劳动.

#1


//请参考
http://kingron.myetang.com/zsfunc0e.htm

#2


编写函数:
Function  TFormFhdCw.XxToDx(const hjnum:real):String;
var Vstr,zzz,cc,cc1,Presult:string;
    xxbb:array[1..12]of string;
    uppna:array[0..9] of string;
    iCount,iZero,vPoint,vdtlno:integer;
begin
  //*设置大写中文数字和相应单位数组*//
  xxbb[1]:='亿';
  xxbb[2]:='仟';
  xxbb[3]:='佰';
  xxbb[4]:='拾';
  xxbb[5]:='万';
  xxbb[6]:='仟';
  xxbb[7]:='佰';
  xxbb[8]:='拾';
  xxbb[9]:='元';
  xxbb[10]:='.';
  xxbb[11]:='角';
  xxbb[12]:='分';
  uppna[0]:='零';
  uppna[1]:='壹';
  uppna[2]:='贰';
  uppna[3]:='叁';
  uppna[4]:='肆';
  uppna[5]:='伍';
  uppna[6]:='陆';
  uppna[7]:='柒';
  uppna[8]:='捌';
  uppna[9]:='玖';
  Str(hjnum:12:2,Vstr);
  cc:='';
  cc1:='';
  zzz:='';
  result:='';
  presult:='';
  iZero:=0;
  vPoint:=0;
  for iCount:=1 to 10 do
    begin
      cc:=Vstr[iCount];
      if cc<>' ' then
        begin
          zzz:=xxbb[iCount];
          if cc='0' then
          begin
            if iZero<1 then  //*对“零”进行判断*//
               cc:='零'
            else
               cc:='';
            if iCount=5 then     //*对万位“零”的处理*//
               if copy(result,length(result)-1,2)='零' then
                  result:=copy(result,1,length(result)-2)+xxbb[iCount]
+'零'
               else
                  result:=result+xxbb[iCount];
            cc1:=cc;
            zzz:='';
            iZero:=iZero+1;
          end
          else
            begin
              if cc='.' then
                begin
                  cc:='';
                  if (cc1='') or (cc1='零')  then
                  begin
                     Presult:=copy(result,1,Length(result)-2);
                     result:=Presult;
                     iZero:=15;
                  end;
                  if iZero>=1 then
                     zzz:=xxbb[9]
                  else
                     zzz:='';
                  vPoint:=1;
                end
              else
                begin
                  iZero:=0;
                  cc:=uppna[StrToInt(cc)];
                end
            end;
          result:=result+(cc+zzz)
        end;
    end;
    If Vstr[11]='0' then   //*对小数点后两位进行处理*//
    begin
       if Vstr[12]<>'0' then
       begin
          cc:='零';
          result:=result+cc;
          cc:=uppna[StrToInt(Vstr[12])];
          result:=result+(uppna[0]+cc+xxbb[12]);
       end
    end
    else
    begin
       if iZero=15 then
       begin
          cc:='零';
          result:=result+cc;
       end;
       cc:=uppna[StrToInt(Vstr[11])];
       result:=result+(cc+xxbb[11]);
       if Vstr[12]<>'0' then
       begin
          cc:=uppna[StrToInt(Vstr[12])];
          result:=result+(cc+xxbb[12]);
       end;
    end;
  result:=result+'正';
end;
请试试

#3


用下面的函数吧,我们很费劲才弄出来的!
              (另外  http://zhangxzh.diy.163.com免费的优秀报表控件!)

function SmallTOBig(small:real):string;
var
   S1,B1,w1,qw1:string;
   qw,dwz,q:integer;
begin
  s1:=formatfloat('0.00',small);  //格式化字符串
  dwz:=pos('.',s1);               //求小数点位置
  qw:=dwz-2;                      //第一位的位值
  for q:=1 to length(s1) do       //从第一位开始循环到最后一位
    begin
    if q<>dwz then                //是点位值跳过
       begin
         case strtoint(copy(S1,q,1)) of
         1:w1:='壹'; 2:w1:='贰';
         3:w1:='叁'; 4:w1:='肆';
         5:w1:='伍'; 6:w1:='陆';
         7:w1:='柒'; 8:w1:='捌';
         9:w1:='玖'; 0:w1:='零';
         end;
         case qw of
         -2:qw1:='分';  -1:qw1:='角';  0 :qw1:='元';
         1 :qw1:='拾';  2 :qw1:='佰';  3 :qw1:='仟';
         4 :qw1:='万';  5 :qw1:='拾';  6 :qw1:='佰';
         7 :qw1:='仟';  8 :qw1:='亿';  9 :qw1:='拾';
         10:qw1:='佰';  11:qw1:='仟';
         end;
         if w1='零' then             //数值是零的情况
            begin
            if (qw=4)or(qw=8) then   //数位是万位和亿位的情况
               begin
               if  ((q+1)<=length(s1))and((q+1)<>dwz) then
                   if (strtoint(copy(S1,q+1,1))<>0) then
                      b1:=b1+qw1+w1
                      else
                      begin
                      if copy(b1,length(b1)-1,2)<>'亿' then b1:=b1+qw1;
                      end;
               end;
            if qw=0 then b1:=b1+qw1;  //数位是个位的情况
            if (qw<>0)and(qw<>4)and(qw<>8) then  //数位不是万位,亿位,个位的情况
               if  ((q+1)<=length(s1))and((q+1)<>dwz) then
                   if (strtoint(copy(S1,q+1,1))<>0) then
                      B1 :=B1+w1;
            end
            else
            begin
            b1:=b1+w1+qw1;            //减位数
            end;
         dec(qw);
       end;
    end;
  SmallTOBig:=B1;
end;

#4


function getdaxie(value:Double): string;
var
    str2,str3,str4,returnje:widestring;
    int1:integer;
    function getme(v1:integer):widestring;
    var
        str1:widestring;
    begin
        str1:='零壹贰叁肆伍陆柒捌玖';
        Result:=Copy(str1,v1+1,1);
    end;
begin
    str2:=FormatFloat('0.00',value);
    str3:=Copy(str2,1,Pos('.',str2)-1);
    str4:=Copy(str2,Pos('.',str2)+1,length(str2)-Pos('.',str2));
    returnje:='';
    returnje:=getme(StrToInt(Copy(str4,2,1)))+returnje+'分';
    returnje:=getme(strToInt(Copy(str4,1,1)))+'角'+returnje;

    if Length(str3)>0 then
    begin
        int1:=StrToInt(Copy(str3,Length(str3),1));
        if int1=0 then
        begin
            if Length(str3)>1 then
                returnje:='元'+returnje
            else
                returnje:=getme(int1)+'元'+returnje;
        end
        else
            returnje:=getme(int1)+'元'+returnje;
    end;
    if Length(str3)>1 then
    begin
        int1:=StrToInt(Copy(str3,Length(str3)-1,1));
        if int1=0 then
        begin
            if StrToInt(Copy(str3,Length(str3),1))<>0 then
                returnje:=getme(int1)+returnje;
        end
        else
            returnje:=getme(int1)+'拾'+returnje;
    end;
    if Length(str3)>2 then
    begin
        int1:=StrToInt(Copy(str3,Length(str3)-2,1));
        if int1=0 then
        begin
            if StrToInt(Copy(str3,Length(str3)-1,1))<>0 then
                returnje:=getme(int1)+returnje;
        end
        else
            returnje:=getme(int1)+'佰'+returnje;
    end;
    if Length(str3)>3 then
    begin
        int1:=StrToInt(Copy(str3,Length(str3)-3,1));
        if int1=0 then
        begin
            if StrToInt(Copy(str3,Length(str3)-2,1))<>0 then
                returnje:=getme(int1)+returnje;
        end
        else
            returnje:=getme(int1)+'仟'+returnje;
    end;
    if Length(str3)>4 then
    begin
        int1:=StrToInt(Copy(str3,Length(str3)-4,1));
        if int1=0 then
            returnje:='万'+returnje
        else
            returnje:=getme(int1)+'万'+returnje;
    end;
    if Length(str3)>5 then
    begin
        int1:=StrToInt(Copy(str3,Length(str3)-5,1));
        returnje:=getme(int1)+'拾'+returnje;
    end;

    Result:=returnje;
end;

#5


哎,,都是这个问题。。

#6


http://qianfeng.diy.163.com/Num2RMB.zip
有个dll和使用说明,直接使用,无需重复劳动.