我采用的是套打
金额的纸张中已经有了万、千、百、十、元等字样
要怎么才可以将数字的金额转换成文字的金额
并将其付给相应的label?
共有5个label
打印的结果要是
label1 万 label2 千 label3 百 label4 十 label5 元
例如
$5300
打印时是:五万三千零百零十零元
其中
万、千、百、十、元
是纸张中原本就印有的

解决方案 »

  1.   

    from  宝典:
    财务软件中总少不了大写的金额表示方式,如下为一个简单的小写金额转换为大写的函数,其思路简单(可以说烂吧,居然利用了位置来转换),但是它却几乎可以无限制的转换,只要你能读得出来和写得进去:
    function Tform1.SmallTOBig(small:real):string;
    var SmallMonth,BigMonth:string;
    wei1,qianwei1:string[2];
    wei,qianwei,dianweizhi,qian:integer;
    begin
    {------- 修改参数令值更精确 -------}
    {小数点后的位数,需要的话也可以改动该值}
    qianwei:=-2;{转换成货币形式,需要的话小数点后加多几个零}
    Smallmonth:=formatfloat('0.00',small);
    {---------------------------------}dianweizhi :=pos('.',Smallmonth);{小数点的位置}{循环小写货币的每一位,从小写的右边位置到左边}
    for qian:=length(Smallmonth) downto 1 do
    begin
    {如果读到的不是小数点就继续} 
    if qian<>dianweizhi then
    begin{位置上的数转换成大写}
    case strtoint(copy(Smallmonth,qian,1)) of1:wei1:='壹'; 2:wei1:='贰';
    3:wei1:='叁'; 4:wei1:='肆';
    5:wei1:='伍'; 6:wei1:='陆';
    7:wei1:='柒'; 8:wei1:='捌';
    9:wei1:='玖'; 0:wei1:='零';
    end;{判断大写位置,可以继续增大到real类型的最大值,可是谁有那么多钱}
    case qianwei of
    -3:qianwei1:='厘';
    -2:qianwei1:='分';
    -1:qianwei1:='角';
    0 :qianwei1:='元';
    1 :qianwei1:='拾';
    2 :qianwei1:='佰';
    3 :qianwei1:='千';
    4 :qianwei1:='万';
    5 :qianwei1:='拾';
    6 :qianwei1:='佰';
    7 :qianwei1:='千';
    8 :qianwei1:='亿';
    9 :qianwei1:='十';
    10:qianwei1:='佰';
    11:qianwei1:='千';
    end;inc(qianwei);
    BigMonth :=wei1+qianwei1+BigMonth;{组合成大写金额}
    end;end;SmallTOBig:=BigMonth;end;程序调用如下“edit1.text:=SmallTOBig(1234567890.1234);”他自动默认小数点后两位
      

  2.   

    假设不考虑过亿的数值,只考虑一亿以下的数值:
    假设有数值 N = 98765432,
    (1)N1 = N MOD 10000 (=5432) // 万位以下
    (2)N2 = N DIV 10000 (=9876) // 万位以上
    (3)T = (N1 DIV 1000) (=5)     // 取千位数值
         sTemp := ConvertNumberToCn(T) + ‘仟’
    (4)N1 = (N1 MOD 1000) (=432)  // 取千位以下数值
    (5)H = (N1 DIV 100)   (=4)    // 取百位数值
         sTemp := sTemp + ConvertNumberToCn(H) + ‘佰’
    (6)N1 = (N1 MOD 100) (=32)    // 取百位以下数值
    (7)T = (N1 DIV 10)   (=3)     // 取十位数值
         sTemp := sTemp + ConvertNumberToCn(T) + ‘拾’
    (8)T = (N1 MOD 10)   (=2)     // 取个位数值
         sTemp := sTemp + ConvertNumberToCn(T) + ‘元’
    同理,利用(3)至 (8)步骤分析 N2 (万位以上数值)
    只是把第(8)步的‘元’改成‘万’函数
    function ConvertNumberToCn(Number:integer) :string
    begin
       Case Number of
          1:Result := '壹';
          2:Result := '贰';
          3:.............
          ...
          9:Result := '玖';
       else
          Result := '零'; 
       end
    end
      

  3.   

    你用EtCell报表控件呀!
    你只要点一下就可以设置为财务大写金额,并且支持套打!EtCell对财务报表是支持的最好的报表工具!
    去看看吧
    http://www.etcell.com/
      

  4.   

    你用EtCell报表控件
    你只要点一下就可以设置为财务大写金额,并且支持套打
    的确很方便!
      

  5.   

    function jisuan(TM:real):string;
    var
        shu: array of string[2];  //保存單位
        shu1: array of string[2]; //保存數字大寫字符
        SHUZI: string;  //保存數字小寫
        ZIFU: string;    //保存數字轉換后的結果
        TMP1: integer;  //臨時變量
    begin
        SetLength(shu,10);SetLength(shu1,10);    shu[9] := '仟';     shu[8] := '佰';     shu[7] := '拾';
        shu[6] := '万';     shu[5] := '仟';     shu[4] := '佰';
        shu[3] := '拾';     shu[2] := '元';     shu[1] := '角';
        shu[0] := '分';    SHU1[0] := '零';    SHU1[1] := '壹';    SHU1[2] := '貳';
        SHU1[3] := '三';    SHU1[4] := '肆';    SHU1[5] := '伍';
        SHU1[6] := '陸';    SHU1[7] := '柒';    SHU1[8] := '捌';
        SHU1[9] := '玖';    //將浮點數數字轉換成字符型數字(保留兩位小數)
        SHUZI := IntToStr(round(TM*100));    if TM>99999999.99 then
            result := 'ERROR'
        else
        begin
            ZIFU := '';
            tmp1 := 1;
            while tmp1<=Length(SHUZI) do
            begin
                if copy(SHUZI,TMP1,1)<>'0' then
                begin
                    if copy(SHUZI,TMP1-1,1)='0' then zifu := zifu+shu1[0];;
                    ZIFU := ZIFU+SHU1[StrToInt(copy(SHUZI,TMP1,1))]+SHU[length(shuzi)-tmp1];
                end;
                if copy(SHUZI,TMP1,1)='0' then
                begin
                    if TMP1=length(SHUZI)-2 then
                        zifu := zifu+SHU[2];
                    if TMP1=length(SHUZI)-6 then
                        zifu := zifu+SHU[6];
                end;
                tmp1 := tmp1+1;
            end;
            RESULT := ZIFU;
        end;
    end;
    可以直接用!!
    絕對正確!
      

  6.   

    假如用String型可用這個函數!!function MoneyUpper(str:string):string;
    var
      shu: array of string[2];  //保存單位
      shu1: array of string[2]; //保存數字大寫字符
      SHUZI: string;   //保存數字小寫
      ZIFU: string;    //保存數字轉換后的結果
      TMP1: integer;  //臨時變量
      iLen: integer;  //字串長度
      str1: string;   //中間變量,保存字串中 點號 前的字串
    begin
      SetLength(shu,14);
      SetLength(shu1,10); //設置字符串長度
      //format(str,'###0.)  //將不符合格式的字串轉為指定格式
      shu[13]:= '仟';
      shu[12]:= '佰';     shu[11]:= '拾';     shu[10] :='億';
      shu[9] := '仟';     shu[8] := '佰';     shu[7] := '拾';
      shu[6] := '万';     shu[5] := '仟';     shu[4] := '佰';
      shu[3] := '拾';     shu[2] := '元';     shu[1] := '角';
      shu[0] := '分';  SHU1[0] := '零';    SHU1[1] := '壹';    SHU1[2] := '貳';
      SHU1[3] := '參';    SHU1[4] := '肆';    SHU1[5] := '伍';
      SHU1[6] := '陸';    SHU1[7] := '柒';    SHU1[8] := '捌';
      SHU1[9] := '玖';  iLen := length(str);  if copy(str,1,1)='-' then
      str:=copy(str,2,iLen);  iLen:= length(str);
      if pos('.',str)<>0 then
      begin
        str1 := copy(str,1,iLen-3);
        str1 :=  str1+copy(str,iLen-1,2);
      end else
      begin
        str1:=str+'00';
      end;
      SHUZI:= str1;  if SHUZI>'99999999999999' then   //最大金額不得超過九仟九佰九十九億....
      begin
        Result :=str+'元整'; 
      end else
      begin
        ZIFU := '';
        tmp1 := 1;
        while tmp1<=Length(SHUZI) do
        begin
          if copy(SHUZI,TMP1,1)<>'0' then
          begin
            if copy(SHUZI,TMP1-1,1)='0' then
               zifu := zifu+shu1[0];
            ZIFU := ZIFU+SHU1[StrToInt(copy(SHUZI,TMP1,1))]+SHU[length(shuzi)-tmp1];
          end;      if copy(SHUZI,TMP1,1)='0' then
          begin
            if TMP1=length(SHUZI)-2 then
            begin
              zifu := zifu+SHU[2];
            end;        if TMP1=length(SHUZI)-6 then
            begin
              zifu := zifu+SHU[6];
            end;
            if TMP1=Length(SHUZI)-10 then
            begin
              ZIFU :=ZIFU+SHU[10];
            end;
          end;
          tmp1 := tmp1+1;
        end; 
        RESULT := ZIFU+'整';
      end;
     end;
      

  7.   

    function UppercaseNumber(nNumber:integer):string;
    const
      UPPERCASENUM:array[0..9]of string[2]=(
        '零','壹','贰','叁','肆','伍','陆','柒','捌','玖'
      )
    var
      I:integer;
    begin
      result:=IntToStr(nNumber);
      for I:=0 to 9 do begin
        stringReplace(result,IntToStr(I),UPPERCASENUM[I]);
      end;
    end;
      

  8.   

    更正:
    function UppercaseNumber(nNumber:integer):string;
    const
      UPPERCASENUM:array[0..9]of string[2]=(
        '零','壹','贰','叁','肆','伍','陆','柒','捌','玖'
      )
    var
      I:integer;
    begin
      result:=IntToStr(nNumber);
      for I:=0 to 9 do begin
        stringReplace(result,IntToStr(I),UPPERCASENUM[I],[rfReplaceAll]);
      end;
    end;