博客新地址

http://wyz.67ge.com/

ASP金额转人民币大写的函数

把As .....这些去掉就能在ASP里用了,网上找来的,测试可用

Public Function UMoney(ByVal money) As String
    Dim lnP As Integer
    Dim Prc As String
    Dim Tmp As String
    Dim NoB As Currency
    Dim Dx As String
    Dim Xx As String
    Dim Zhen As Boolean
    Dim China As String: China = "分角元拾佰仟万拾佰仟亿"
    Dim str: str = Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖")
    Zhen = True
    money = FormatNumber(money, 2)
    Prc = CStr(money)
    Prc = Replace(Prc, ",", "")
   
    lnP = Len(Prc)
    For i = lnP - 1 To 1 Step -1
        If Mid(Prc, i, 1) = "." Then
            Select Case lnP - i
                Case 1
                    Prc = Replace(Prc, ".", "") + "0"
                Case 2
                    Prc = Replace(Prc, ".", "")
            End Select
            Zhen = False
            Exit For
        End If
    Next
    If Zhen Then Prc = Prc + "00"
    lnP = Len(Prc)
    For i = 1 To lnP
        Tmp = str(Mid(Prc, i, 1)) & Tmp
    Next
    UMoney = ""
    fy = 1
    For i = 1 To lnP
        Xx = Mid(Tmp, i, 1)
        Dx = Mid(China, i, 1)
       
        If Xx <> "零" Then
            UMoney = Xx & Dx & UMoney
            f = 1
        Else
            If i = 3 Then
            UMoney = Dx & UMoney
            End If
       
            If i = 7 Then
                UMoney = Dx & UMoney
            End If
            If f Then
                UMoney = "零" & UMoney
            End If
            f = 0
        End If
    Next
    If Zhen Then UMoney = UMoney + "整"
    UMoney = Replace(UMoney, "零万", "万")
    UMoney = Replace(UMoney, "零元", "元")
End Function
posted @ 2008-05-07 17:53  yongzhi  阅读(905)  评论(0编辑  收藏  举报

博客新地址

http://wyz.67ge.com/