如何将123转化为壹贰叁!(急!!!在线等待)

解决方案 »

  1.   

    1.定义函数num—str 
      function num—str(ls: Variant): String; 
      var 
       dx—sz,dx—dw,str—int,str—dec,dx—str,fu:string; 
       a,b,b2,c,d:string; 
       num—int,num—dec,len—int,i,a—int,pp:integer; 
      //dx—str为返回字符串 
      begin 
      dx—sz:=′零壹贰叁肆伍陆柒捌玖′; 
      dx—dw:=′万仟佰拾亿仟佰拾万仟佰拾元′; 
      //处理金额小于零情况 
      if ls〈0 then 
      begin 
       ls:=ls(-1); 
       fu:=′负′; 
      end else fu:=′′; 
      //取得整数值及整数串 
      dx—str:=ls; 
      if (ls〉0)and(ls〈1) then dx—str:=′0′+dx—str; 
      pp:=pos(′.′,dx—str); 
      if pp〉0 then str—int:=copy(dx—str,1,pos(′.′,dx—str)-1) 
      else str—int:=dx—str; 
      num—int:=strtoint(str—int); 
      //取得小数值及小数串 
      if (ls〉0)and(ls〈1) then num—dec:=ls100 
      else num—dec:=(ls-num—int)100; 
      str—dec:=inttostr(num—dec); 
      len—int:=Length(str—int); 
       dx—str:=′′; 
      //转换整数部分 
       for i:=1 to len—int do 
       begin 
      //a为小写数字字符,b为对应的大写字符 
      //c为对应大写单位,d为当前大写字符串的最后一个汉字 
       a:=copy(str—int,i,1); 
       a—int:=strtoint(a); 
       b:=copy(dx—sz,(a—int2+1),2); 
       c:=copy(dx—dw,((13-len—int+i-1)2+1),2); 
       if dx—str〈〉′′ then 
       d:=copy(dx—str,Length(dx—str)-1,2) 
       else d:=′′; 
       if (b=′零′)and((d=′零′)or(b=b2)or(c=′元′)or(c=′万′)or(c=′亿′)) then b:=′′; 
       if (a=′0′)and(c〈〉′元′)and(c〈〉万′′)and(c〈〉′亿′) then c:=′′; 
       if ((c=′元′)or(c=′万′)or(c=′亿′))and (d=′零′)and(a=′0′) then 
       begin 
       dx—str:=copy(dx—str,1,Length(dx—str)-2); 
       d:=copy(dx—str,Length(dx—str)-1,2); 
       if ((c=′元′)and(d=′万′))or((c=′万′)and(d=′亿′)) then c:=′′; 
       end; 
       dx—str:=dx—str+b+c; b2:=b; 
       end; 
      //处理金额小于1的情况 
      if Length(dx—str)〈=2 then dx—str:=′′; 
      //转换小数部分 
      if (num—dec〈10)and(ls〉0) then 
      begin 
      a—int:=strtoint(str—dec); 
      b:=copy(dx—sz,(a—int2+1),2); 
      if num—dec=0 then dx—str:=dx—str+′整′; 
      if num—dec〉0 then dx—str:=dx—str+′零′+b+′分′; 
      end; 
      if num—dec〉=10 then 
      begin 
      a—int:=strtoint(copy(str—dec,1,1)); 
      a:=copy(dx—sz,(a—int2+1),2); 
      a—int:=strtoint(copy(str—dec,2,1)); 
      b:=copy(dx—sz,(a—int2+1),2); 
      if a〈〉′零′ then a:=a+′角′; 
      if b〈〉′零′ then b:=b+′分′ 
      else b:=′′; 
      dx—str:=dx—str+a+b; 
       end; 
       if ls=0 then dx—str:=′零元整′; 
       dx—str:=fu+dx—str; 
      //函数返回字符串 
       Result:=dx—str; 
      end; 
      2.调用方法 
      函数参数采用Variant类型,调用时参数值可以是实型,也可以是字符串,非常方便,下面举例说明: 
      新建窗口,在相应pas文件中加入num—str函数,并在窗口中添加Button1和Edit1、Edit2控件,双击Button1输入以下代码,运行程序即可: 
       procedure TForm1.Button1Click(Sender: TObject); 
       begin 
       Edit1.text:=num—str(202055010.32); 
       //也可以在Edit2中输入数串调用 
       //Edit1.text:=num—str(Edit2.text); 
       end; 
      

  2.   

    function Tfrm_printpass_check.cutnumber(num: integer): string;
    begin
          case num of
              0:
                Result:='零';
              1:
                Result:='壹';
              2:
                Result:='贰';
              3:
                Result:='叁';
              4:
                Result:='肆';
              5:
                Result:='伍';
              6:
                Result:='陆';
              7:
                Result:='柒';
              8:
                Result:='捌';
              9:
                Result:='玖';
              10:
                Result:='拾';
          end;end;
      

  3.   

    一个函数:
    function conver:(value:String)String
    const  
      a:array [0..10] of string=('零','壹','贰','叁','肆','伍','陆','柒','捌','玖','拾');
    var
      i:integer;
      constr:string;
    begin
      constr:='';
      for i:=0 to length(value) do
        constr:=constr+a[strtoint(value[i])];
      result:=constr;
    end;
      

  4.   

    digital:=123;
    str//将digital转化到这儿
    procedure Change(digital:int):string;
    var temp:string;
        i:integer;
        str:string;
    begin
      str:='';
      temp:=strtoint(digital);
      for i:=1 to length(temp) do
        begin
           case strtoint(temp[1]) of
             1: str:=str+'壹';
             2: str:=str+'贰';
             ...............
           end;
        end;
      result:=str;
    end;
      

  5.   

    function SV(const Int: Integer): string;
    var
      S: string;
      i: Integer;
    begin
      Result := '';
      S := IntToStr(Int);
      for i := 1 to Length(S) do
        case S[i] of
          '1': Result := Result + '壹';
          '2': Result := Result + '贰';
          '3': Result := Result + '叁';
        end;
    end;procedure TForm1.Button4Click(Sender: TObject);
    begin
      Caption := SV(213);
    end;
      

  6.   

    哇塞~~~~
    居然我不是第一个回复的啊 ~~~~~~
    呵呵~不过我的是比较简单的~代码也看起来简单~ haoco(程序员) ( )  的也不错~
      

  7.   

    查看
    http://www.csdn.net/Develop/Read_Article.asp?Id=6560
      

  8.   

    你找一下吧有这样现成的function  ,实在找不到的话通知我我给你一个现在我这没带呀。OK!