2017-03-05 59 views
0

我要將科威特第納爾的數值轉換爲Excel中的單詞,例如:
120.050 KWD =一百二十科威特第納爾和五十隻只。
100 KWD =僅一百科威特第納爾。將數字轉換成科威特第納爾的單詞

+0

以下答案是否解決了您的問題?可能是我可以幫你一點。 – harun24hr

回答

0

這可以通過使用模運算來完成:

Function NumberToFullProseForm(value As Decimal) As String 

    Dim value As Decimal = 120.050 

    Dim v100 As Decimal = (value % 100)/100 
    Dim v10 As Decimal = (value % 10)/10 
    Dim v1 As Decimal = value % 1 
    Dim v01 As Decimal = (value * 10) % 1 
    Dim v001 As Decimal = (value * 100) % 1 

    Dim output = 
     DigitToText(v100) + " Hundred and " + 
     DigitToTens(v10) + " and " + 
     DigitToText(v1) + " Dinars and" + 
     DigitToText(v01) + " Tens" + 
     DigitToText(vv001) + " Cents" 

    Return output 
End Function 

Function DigitToText(digit As Char) As String 

    If digit = 0 Then Return "Zero" 
    If digit = 1 Then Return "One" 
    ' etc 
End Function 

Function DigitToTens(digit As Char) As String 
    If digit = 0 Then Return "" 
    If digit = 1 Then Return "Ten" 
    If digit = 2 Then Return "Twenty" 
    ' etc 
End Function 

調整爲,是必要的。

+0

這是特定區域的功能嗎?我在我的Excel 2007中沒有任何'Decimal'數據類型。 – harun24hr