请大虾帮看看,用什么方法实现比较好一点?要做财务方面的报表,
要一个金额,分配到万,千,百,十,元,角,分上..如,金额:13600.00元在报表里显示为:万 千 百 十 元 角 分
1  3  6  0  0  0  0

解决方案 »

  1.   

    function IntToDelimiterStr(Value, Separate: Integer): AnsiString;
    var i: integer;
    begin
      Result:= inttostr(Value);
      for i := length(Result) downto 2 do
        insert(StringOfChar(#32,Separate),Result,i);
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      edit1.Text:=IntToDelimiterStr(123456,3);//用3个空格作一个分隔符进行分隔
    end;
      

  2.   

    如果仅用一个(或固定数的)空格来分隔的话,函数可省略一个参数:function IntToDelimiterStr(Value): AnsiString;
    var i: integer;
    begin
      Result:= inttostr(Value);
      for i := length(Result) downto 2 do insert(StringOfChar(#32,1),Result,i);
    end;
      

  3.   

    5楼的参数漏了类型定义“Integer”,请自修改,还可以给第二参数给定一个默认值:function IntToDelimiterStr(Value: Integer; const Separate: integer= 3): AnsiString;
    var i: integer;
    begin
      Result:= inttostr(Value);
      for i := length(Result) downto 2 do insert(StringOfChar(#32,Separate),Result,i);
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      edit1.Text:=IntToDelimiterStr(123456);//用3个空格作一个分隔符时,第二个参数可省略;其他数目则不能省。
    end;
      

  4.   

    财务报表都是套打的格式,在对应的位置填入数字就行了
    比如要显示金额10位,包括2位小数(角,分)
    则添加10个Memo控件Memo1..Memo10,从左到右摆在对应的上然后在脚本中处理,取出每一位赋值,算法很简单,自己想想吧
    Memo10.Text:='0';
    Memo9.Text:='0';
    Memo8.Text:='0';
    Memo7.Text:='0';
    Memo6.Text:='6';
    Memo5.Text:='3';
    Memo4.Text:='1';
      

  5.   

    使用7楼的方法可以实现。如果楼主肯研究一下reportmachine也可以。它里面有这个控件。