如:97720
变为NINETY SEVEN THOUSAND SEVEN HUNDRED TWENTY

解决方案 »

  1.   

    分 aaa'bbb'ccc 进行判断 和基本的结合就可以了
      

  2.   

    如:97720
    变为NINETY SEVEN THOUSAND SEVEN HUNDRED TWENTY只能自己写.
    把你转换的方式说说.为什么97720可以转换成下面的英文?
    有点类似加密了
      

  3.   

    '***************** Convert long integer to English *********************
    Private Function LongToText(ByVal lngVal As Long) As String
        Dim arrOnes(0 To 9) As String
        Dim arrTeens(0 To 9) As String
        Dim arrTens(0 To 9) As String
        Dim arrThousands(0 To 4) As String
        Dim blnInit As Boolean
        Dim i As Integer, blnAllZeros As Boolean, blnShowstrThousands As Boolean
        Dim strVal As String, strBuff As String, strTemp As String
        Dim intCol As Integer, intChar As Integer    'Only handles positive values
        Debug.Assert lngVal >= 0    If blnInit = False Then
            'Initialize array
            blnInit = True
            arrOnes(0) = "zero"
            arrOnes(1) = "one"
            arrOnes(2) = "two"
            arrOnes(3) = "three"
            arrOnes(4) = "four"
            arrOnes(5) = "five"
            arrOnes(6) = "six"
            arrOnes(7) = "seven"
            arrOnes(8) = "eight"
            arrOnes(9) = "nine"
            arrTeens(0) = "ten"
            arrTeens(1) = "eleven"
            arrTeens(2) = "twelve"
            arrTeens(3) = "thirteen"
            arrTeens(4) = "fourteen"
            arrTeens(5) = "fifteen"
            arrTeens(6) = "sixteen"
            arrTeens(7) = "seventeen"
            arrTeens(8) = "eighteen"
            arrTeens(9) = "nineteen"
            arrTens(0) = ""
            arrTens(1) = "ten"
            arrTens(2) = "twenty"
            arrTens(3) = "thirty"
            arrTens(4) = "forty"
            arrTens(5) = "fifty"
            arrTens(6) = "sixty"
            arrTens(7) = "seventy"
            arrTens(8) = "eighty"
            arrTens(9) = "ninety"
            arrThousands(0) = ""
            arrThousands(1) = "thousand"
            arrThousands(2) = "million"
            arrThousands(3) = "billion"
            arrThousands(4) = "trillion"
        End If
        'Trap errors
        On Error GoTo ErrHandle
        'Convert rest to string and process each digit
        strVal = CStr(lngVal)
        'Non-zero digit not yet encountered
        blnAllZeros = True
        'Iterate through string
        For i = Len(strVal) To 1 Step -1
            'Get value of this digit
            intChar = Val(Mid$(strVal, i, 1))
            'Get column position
            intCol = (Len(strVal) - i) + 1
            'Action depends on 1's, 10's or 100's column
            Select Case (intCol Mod 3)
                Case 1  '1's position
                    blnShowstrThousands = True
                    If i = 1 Then
                        'First digit in number (last in loop)
                        strTemp = arrOnes(intChar) & " "
                    ElseIf Mid$(strVal, i - 1, 1) = "1" Then
                        'This digit is part of "teen" number
                        strTemp = arrTeens(intChar) & " "
                        i = i - 1   'Skip arrTens position
                    ElseIf intChar > 0 Then
                        'Any non-zero digit
                        strTemp = arrOnes(intChar) & " "
                    Else
                        'This digit is zero. If digit in arrTens and hundreds column
                        'are also zero, don't show "arrThousands"
                        blnShowstrThousands = False
                        'Test for non-zero digit in this grouping
                        If Mid$(strVal, i - 1, 1) <> "0" Then
                            blnShowstrThousands = True
                        ElseIf i > 2 Then
                            If Mid$(strVal, i - 2, 1) <> "0" Then
                                blnShowstrThousands = True
                            End If
                        End If
                        strTemp = ""
                    End If
                    'Show "arrThousands" if non-zero in grouping
                    If blnShowstrThousands Then
                        If intCol > 1 Then
                            strTemp = strTemp & arrThousands(intCol \ 3)
                            If blnAllZeros Then
                                strTemp = strTemp & " "
                            Else
                                strTemp = strTemp & ", "
                            End If
                        End If
                        'Indicate non-zero digit encountered
                        blnAllZeros = False
                    End If
                    strBuff = strTemp & strBuff
                Case 2  '10's position
                    If intChar > 0 Then
                        If Mid$(strVal, i + 1, 1) <> "0" Then
                            strBuff = arrTens(intChar) & "-" & strBuff
                        Else
                            strBuff = arrTens(intChar) & " " & strBuff
                        End If
                    End If
                Case 0  '100's position
                    If intChar > 0 Then
                        strBuff = arrOnes(intChar) & " hundred " & IIf(blnAllZeros, "", "and ") & strBuff
                    End If
            End Select
        Next i
        'Convert to upper case
        strBuff = UCase$(Trim$(strBuff))
    ProcExit:
        'Return result
        LongToText = strBuff
        Exit Function
    ErrHandle:
        strBuff = ""
        Resume ProcExit
    End Function
      

  4.   

    leolan(史留香) ( ) 信誉:130 老大,太感激了