请问各位,阿拉伯数字表示的金额转换英文大写表示的金额,如何做?有现成的可调用的工具吗?
例如:9126--〉NINE THOUSAND ONE HUNDRED AND TWENTY SIX

解决方案 »

  1.   

    Function Fun_换算中国数目字(数值 As String) As String
        Dim TempIt(1 To 28), Temp As String
        Dim TempLen, i, TempItNow As Integer
        Dim IntNum As String
        Dim Nums As String
        Dim Zero As Boolean    TempIt(1) = ""
        TempIt(2) = "拾"
        TempIt(3) = "佰"
        TempIt(4) = "仟"
        TempIt(5) = ""  '万            万
        TempIt(6) = "拾" '十万
        TempIt(7) = "佰" '百万
        TempIt(8) = "仟" '千万
        TempIt(9) = "" '亿             亿
        TempIt(10) = "拾" '十亿
        TempIt(11) = "佰" '百亿
        TempIt(12) = "仟" '千亿
        TempIt(13) = "" '万亿          万
        TempIt(14) = "拾" '十万亿
        TempIt(15) = "佰" '百万亿
        TempIt(16) = "仟" '千万亿
        TempIt(17) = ""     '兆        兆
        TempIt(18) = "拾"  '十兆
        TempIt(19) = "佰" '百兆
        TempIt(20) = "仟" '千兆
        TempIt(21) = "" '万兆          万
        TempIt(22) = "拾" '十万兆
        TempIt(23) = "佰" '百万兆
        TempIt(24) = "仟" '千万兆
        TempIt(25) = "" '亿万兆        亿
        TempIt(26) = "拾" '十亿万兆
        TempIt(27) = "佰" '百亿万兆
        TempIt(28) = "仟" '千万亿兆
        Nums = "壹贰叁肆伍陆柒捌玖"    IntNum = 数值 '取值
        TempLen = Len(IntNum)    Fun_换算中国数目字 = ""    Zero = False    For i = 1 To TempLen
            TempItNow = Val(Mid(IntNum, i, 1))
            Temp = TempIt(TempLen - i + 1)
            If TempItNow <> 0 Then
                If Zero = True Then
                    Fun_换算中国数目字 = Fun_换算中国数目字 + "零"
                    Zero = False
                End If
               
                If i = 1 And TempItNow = 1 And Temp = "拾" Then
                    Fun_换算中国数目字 = Fun_换算中国数目字 + "拾"
                Else
                    Fun_换算中国数目字 = Fun_换算中国数目字 + Mid(Nums, TempItNow, 1) + Temp
                End If
            Else
                If Zero = False Then
                    Zero = True
                End If
            End If
        
            Select Case TempLen - i + 1
                Case 5
                    Fun_换算中国数目字 = Fun_换算中国数目字 + "万"
                Case 9
                    Fun_换算中国数目字 = Fun_换算中国数目字 + "亿"
                Case 13
                    Fun_换算中国数目字 = Fun_换算中国数目字 + "万"
                Case 17
                    Fun_换算中国数目字 = Fun_换算中国数目字 + "兆"
                Case 21
                    Fun_换算中国数目字 = Fun_换算中国数目字 + "万"
                Case 25
                    Fun_换算中国数目字 = Fun_换算中国数目字 + "亿"
            End Select
        NextEnd Function
      

  2.   

    试试这个,然后在这个基础上改
    Private Sub Command1_Click()
    Label1.Caption = rmb(Text1.Text)
    End SubPublic Function rmb(s As Currency) As String
        s1$ = LTrim(Str$(Abs(s)))
        L% = Len(s1)
        Select Case L - InStrRev(s1, ".")
        '双引号内是小数点
           Case L
             s2$ = s1 + ".00"
           Case 1
             s2$ = s1 + "0"
           Case 2
             s2$ = s1
        End Select
        L = Len(s2)
        DX$ = ""
        C1$ = "零壹贰叁肆伍陆柒捌玖"
        C2$ = "分角 元拾佰仟万拾佰仟亿拾佰"
        '角和元之间留一个空格
         Do While L >= 1
         x$ = Mid(s2, Len(s2) - L + 1, 1)
         DX = DX + IIf(x <> ".", Mid(C1, Val(x) + 1, 1) + Trim(Mid(C2, (L - 1) + 1, 1)), "")
         L = L - 1
         Loop
         rmb = DX + "整"
    End Function
      
      

  3.   

    Option Explicit
    Public Function numtoword(numstr As Variant) As String
    '----------------------------------------------------
    ' The best data type to feed in is
    ' Decimal, but it is up to you
    '----------------------------------------------------
    Dim tempstr As String
    Dim newstr As String
    numstr = CDec(numstr)If numstr = 0 Then
    numtoword = "zero "
    Exit Function
    End IfIf numstr > 10 ^ 24 Then
    numtoword = "Too big"
    Exit Function
    End IfIf numstr >= 10 ^ 12 Then
    newstr = numtoword(Int(numstr / 10 ^ 12))
    numstr = ((numstr / 10 ^ 12) - Int(numstr / 10 ^ 12)) * 10 ^ 12
    If numstr = 0 Then
    tempstr = tempstr & newstr & "billion "
    Else
    tempstr = tempstr & newstr & "billion, "
    End If
    End IfIf numstr >= 10 ^ 6 Then
    newstr = numtoword(Int(numstr / 10 ^ 6))
    numstr = ((numstr / 10 ^ 6) - Int(numstr / 10 ^ 6)) * 10 ^ 6
    If numstr = 0 Then
    tempstr = tempstr & newstr & "million "
    Else
    tempstr = tempstr & newstr & "million, "
    End If
    End IfIf numstr >= 10 ^ 3 Then
    newstr = numtoword(Int(numstr / 10 ^ 3))
    numstr = ((numstr / 10 ^ 3) - Int(numstr / 10 ^ 3)) * 10 ^ 3
    If numstr = 0 Then
    tempstr = tempstr & newstr & "thousand "
    Else
    tempstr = tempstr & newstr & "thousand, "
    End If
    End IfIf numstr >= 10 ^ 2 Then
    newstr = numtoword(Int(numstr / 10 ^ 2))
    numstr = ((numstr / 10 ^ 2) - Int(numstr / 10 ^ 2)) * 10 ^ 2
    If numstr = 0 Then
    tempstr = tempstr & newstr & "hundred "
    Else
    tempstr = tempstr & newstr & "hundred and "
    End If
    End IfIf numstr >= 20 Then
    Select Case Int(numstr / 10)
    Case 2
    tempstr = tempstr & "twenty "
    Case 3
    tempstr = tempstr & "thirty "
    Case 4
    tempstr = tempstr & "forty "
    Case 5
    tempstr = tempstr & "fifty "
    Case 6
    tempstr = tempstr & "sixty "
    Case 7
    tempstr = tempstr & "seventy "
    Case 8
    tempstr = tempstr & "eighty "
    Case 9
    tempstr = tempstr & "ninety "
    End Select
    numstr = ((numstr / 10) - Int(numstr / 10)) * 10
    End IfIf numstr > 0 Then
    Select Case numstr
    Case 1
    tempstr = tempstr & "one "
    Case 2
    tempstr = tempstr & "two "
    Case 3
    tempstr = tempstr & "three "
    Case 4
    tempstr = tempstr & "four "
    Case 5
    tempstr = tempstr & "five "
    Case 6
    tempstr = tempstr & "six "
    Case 7
    tempstr = tempstr & "seven "
    Case 8
    tempstr = tempstr & "eight "
    Case 9
    tempstr = tempstr & "nine "
    Case 10
    tempstr = tempstr & "ten "
    Case 11
    tempstr = tempstr & "eleven "
    Case 12
    tempstr = tempstr & "twelve "
    Case 13
    tempstr = tempstr & "thirteen "
    Case 14
    tempstr = tempstr & "fourteen "
    Case 15
    tempstr = tempstr & "fifteen "
    Case 16
    tempstr = tempstr & "sixteen "
    Case 17
    tempstr = tempstr & "seventeen "
    Case 18
    tempstr = tempstr & "eighteen "
    Case 19
    tempstr = tempstr & "nineteen "
    End Select
    numstr = ((numstr / 10) - Int(numstr / 10)) * 10
    End If
    numtoword = tempstr
    End Function'在程序中使用实例
    Private Sub Command1_Click()
        Debug.Print numtoword("1234")
    End Sub