金额拆分 "万千百"..

     

      很多情况下,比如存折,合同等都要这样表示金额,现在来看看如何实现:

   

ExpandedBlockStart.gif View Code
< table  width ="100%"  border ="0"  cellspacing ="0"  cellpadding ="0" >
                 < tr >
                   < td  width ="10%"  height ="60"  valign ="middle"  align ="center" > &nbsp; < br  />< br  /> &nbsp; < br  />< br  /> &nbsp; </ td >
                   < td  width ="90%"  height ="60"  valign ="middle"  align ="center"    >< table  width ="220"  height ="47"  class ="main_bg1 "  border ="0"  cellspacing ="0"  cellpadding ="0"   >
                     < tr >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"   class ="main_bg2" ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"  class ="main_bg2" ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"  class ="main_bg2" ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"  class ="main_bg2" ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"  class ="main_bg2" ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"  class ="main_bg2" ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"  class ="main_bg2" ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"  class ="main_bg2" ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"  class ="main_bg2" ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"  class ="main_bg2" ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"  class ="main_bg2" ></ td >
                     </ tr >
                     < tr >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"  class ="main_bg3" >< asp:Literal  ID ="Literal1"  runat ="server" ></ asp:Literal ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"   class ="main_bg3" >< asp:Literal  ID ="Literal2"  runat ="server" ></ asp:Literal ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"   class ="main_bg3" >< asp:Literal  ID ="Literal3"  runat ="server" ></ asp:Literal ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"   class ="main_bg3" >< asp:Literal  ID ="Literal4"  runat ="server" ></ asp:Literal ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"   class ="main_bg3" >< asp:Literal  ID ="Literal5"  runat ="server" ></ asp:Literal ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"   class ="main_bg3" >< asp:Literal  ID ="Literal6"  runat ="server" ></ asp:Literal ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"   class ="main_bg3" >< asp:Literal  ID ="Literal7"  runat ="server" ></ asp:Literal ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"   class ="main_bg3" >< asp:Literal  ID ="Literal8"  runat ="server" ></ asp:Literal ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"  class ="main_bg3" >< asp:Literal  ID ="Literal9"  runat ="server" ></ asp:Literal ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"  class ="main_bg3" >< asp:Literal  ID ="Literal10"  runat ="server" ></ asp:Literal ></ td >
                       < td  width ="20"  height ="22"  align ="center"  valign ="middle"   class ="main_bg3" >< asp:Literal  ID ="Literal11"  runat ="server" ></ asp:Literal ></ td >
                     </ tr >
                    
                   </ table >

后台程序中:

 

ExpandedBlockStart.gif View Code
  // 将金额分解
     private  void GetMoney( string num)
    {
         string money = num.ToString();
         int index1 = money.LastIndexOf( " . ") +  1;
         string zmoeny = "";
         if (money.LastIndexOf( " . ") == - 1)
        {
            Literal11.Text =  " 0 ";
            Literal10.Text =  " 0 ";
            zmoeny = num;
        }
         else
        {
            zmoeny = money.Substring( 0, index1 -  1);
            Literal11.Text = money.Substring(index1+ 11);
            Literal10.Text = money.Substring(index1,  1);
          
        }
        zcdate.Value = zmoeny;

         string[] dw =  new  string[ 9];
         int aa = dw.Length - zmoeny.Length;
         for ( int i = dw.Length -  1; i >=  0; i--)
        {
             if (i >= aa)
            {
                dw[i] = zmoeny[i - aa].ToString();
            }
             else  if(i==aa- 1)
            {
                dw[i] =  " ";
            } else{
                dw[i] =  "";
            }
        }
        Literal1.Text = dw[ 0].ToString();
        Literal2.Text = dw[ 1].ToString();
        Literal3.Text = dw[ 2].ToString();
        Literal4.Text = dw[ 3].ToString();
        Literal5.Text = dw[ 4].ToString();
        Literal6.Text = dw[ 5].ToString();
        Literal7.Text = dw[ 6].ToString();
        Literal8.Text = dw[ 7].ToString();
        Literal9.Text = dw[ 8].ToString();
    }

 

 上面是我自己写的,有什么不妥之处,希望大家指正!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值