VB阿拉伯数字金额转大写中文

Function mychange(ByVal Myinput)
    Dim Temp, TempA, MyinputA, MyinputB, MyinputC
    Dim Place As String
    Dim J As Integer
    Place = "分角元拾佰仟万拾佰仟亿拾佰仟万"
    shuzi1 = "壹贰叁肆伍陆柒捌玖"
    shuzi2 = "整零元零零零万零零零亿零零零万"
    
    qianzhui = ""
    If Val(Myinput) = 0 Then Myinput = 0
    If Myinput = "" Then Myinput = 0
    If Myinput < 0 Then qianzhui = "负"
    Myinput = Int(Abs(Myinput) * 100 + 0.5)
    If Myinput > 999999999999999# Then
      mychange = "数字太大了吧???"
      Exit Function
    End If
    If Myinput = 0 Then
      mychange = "零元零分"
      Exit Function
    End If
    
    MyinputA = Trim(Str(Myinput))
    shuzilong = Len(MyinputA)
    For J = 1 To shuzilong
    MyinputB = Mid(MyinputA, J, 1) & MyinputB
    Next
    For J = 1 To shuzilong
      Temp = Val(Mid(MyinputB, J, 1))
      If Temp = 0 Then
         MyinputC = Mid(shuzi2, J, 1) & MyinputC
      Else
         MyinputC = Mid(shuzi1, Temp, 1) & Mid(Place, J, 1) & MyinputC
      End If
    Next
    
    shuzilong = Len(MyinputC)
    For J = 1 To shuzilong - 1
      If Mid(MyinputC, J, 1) = "零" Then
         Select Case Mid(MyinputC, J + 1, 1)
            Case "零", "元", "万", "亿", "整":
            MyinputC = Left(MyinputC, J - 1) & Mid(MyinputC, J + 1, 30)
            J = J - 1
         End Select
      End If
    Next
    
    shuzilong = Len(MyinputC)
    For J = 1 To shuzilong - 1
       If Mid(MyinputC, J, 1) = "亿" And Mid(MyinputC, J + 1, 1) = "万" Then
         MyinputC = Left(MyinputC, J) & Mid(MyinputC, J + 2, 30)
         Exit For
       End If
    Next
    
    mychange = qianzhui & Trim(MyinputC)
    
End Function
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值