[其他]水晶報表中的人民幣大寫函數

來源:互聯網
上載者:User

Function RMB ( ls as Currency) as string
      Dim  dblAmount as Double
      Dim   MA1(14)   as   string   ,MA2(14)   as   string,   x   as   string,   y   as   string,   Y1,   LML   As   number  
      Dim   NS   as   number,   NS0   As   Currency  
      Dim   i   As   number  
   
      dblAmount = CDbl(ls)
      MA1(   1)   =   "分"  
      MA1(   2)   =   "角"  
      MA1(   3)   =   "元"  
      MA1(   4)   =   "拾"  
      MA1(5)   =   "佰"  
      MA1(6)   =   "仟"  
      MA1(7)   =   "萬"  
      MA1(8)   =   "拾"  
      MA1(9)   =   "佰"  
      MA1(10)   =   "仟"  
      MA1(11)   =   "億"  
      MA1(12)   =   "拾"  
      MA1(13)   =   "佰"  
      MA1(14)   =   "仟"  
      MA2(1)   =   "壹"  
      MA2(2)   =   "貳"  
      MA2(3)   =   "三"  
      MA2(4)   =   "肆"  
      MA2(5)   =   "伍"  
      MA2(6)   =   "陸"  
      MA2(7)   =   "柒"  
      MA2(8)   =   "捌"  
      MA2(9)   =   "玖"  
   
      x   =   "整"  
      y   =   replace(Trim(CStr(dblAmount)),",","")  
     
   
      If   InStr(y,   ".")   =   0   Then  
          y   =   y   +   "00"  
          Else  
              LML   =   InStr(y,".")  
              y   =   Left(y,   LML   -   1)   +   Left(Mid(y,   LML   +   1)   +   "00",   2)  
      End   If  
   
      NS0   =   0  
      LML   =Len(y)  
      For   i   =   1   To   LML  
          Y1   =   Mid(y,   LML   -   i   +   1,   1)  
          NS   =   val(Y1)  
          If   NS   <>   0   Then  
              x   =MA2(NS)   +   MA1(i)   +x  
          ElseIf   MA1(i)   =   "元"   Or   MA1(i)   =   "萬"   Then  
              x   =   MA1(   i)   +   x  
          End   If  
          If   i   <=   2   Then  
              NS0   =   0  
          ElseIf   NS   =   0   And   NS0   <>   0   Then  
              x   =   "零"   +   x  
              NS0   =   0  
          ElseIf   i   =   6   Then  
              NS0   =   0  
          Else  
              NS0   =   NS  
          End   If  
      Next   i  
      If   dblAmount   <   0   Then  
          x   =   "負"   +   Right(x,   Len(x)   -   1)  
      End   If  
      If   x   =   "元整"   Then  
          x   =   "零"   +   x  
      End   If  

      RMB   =   x  
End Function

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.