Convert Numbers to Arabic Language Text

A

Abdul

Hello All,

There is code available for converting a number to its equivalent
English Text. (Like 1= "One")
Do any one here have a code to convert numbers to Arabic Language Text?

Thanks

Abdul
 
B

Bernie Deitrick

Abdul,

A lot depends on the word structure in Arabic. For example, I helped someone convert the standard
'number to word' function to Italian, which has different words depending on the level - for
example, "unmilione" for 1 million, and "milioni" for multiples. I have copied the code for the
Italian conversion below - you would basically need to change each quoted value to the appropriate
word in Arabic. (That, I can't help you with.) But if there is additional structure needed in the
function, post back, and I can help you with that.

The function, as written, is used like

=Conversion(A1)

where A1 has a number that needs to be converted to words.

HTH,
Bernie
MS Excel MVP


Function conversion(inRange As Range) As String

conversion = ""

n = inRange.Value

'Do Billions
bill = n / 1000000000
If Int(bill) > 0 Then
If Int(bill) = 1 And ((Int(bill) - bill) < 0) Then
conversion = "unmiliardo"
Else
conversion = MakeWord(Int(bill)) & "miliardi"
End If
End If

'Do millions
n = n - Int(bill) * 1000000000
mill = n / 1000000
If Int(mill) > 0 Then
If Int(mill) = 1 And ((Int(mill) - mill) < 0) Then
conversion = "unmilione"
Else
conversion = conversion & MakeWord(Int(mill)) & "milioni"
End If
End If

'Do Thousands
n = n - Int(mill) * 1000000
thou = n / 1000
If Int(thou) > 0 Then
If Int(thou) = 1 And ((Int(thou) - thou) < 0) Then
conversion = "mille"
Else
conversion = conversion & MakeWord(Int(thou)) & "mila"
End If
End If

'Do the rest
n = n - Int(thou) * 1000
conversion = conversion & MakeWord(Int(n))

conversion = Application.WorksheetFunction.Proper(Trim(conversion))
End Function

Function MakeWord(inValue As Integer) As String
'Enter the counting words: one, two, three... up to 19
unitWord = Array("", "uno", "due", "tre", "quattro", "cinque", _
"sei", "sette", "otto", "nove", "dieci", "undici", _
"dodici", "tredici", "quattordici", "quindici", "sedici", _
"diciassette", "diciotto", "diciannove")
'enter the decade words - 10, 20, etc.
tenWord = Array("", "dieci", "venti", "trenta", "quaranta", "cinquanta", _
"sessanta", "settanta", "ottanta", "novanta")
MakeWord = ""
n = inValue
If n = 0 Then
MakeWord = ""
End If

'Do the nundreds
hund = n \ 100
If hund > 0 Then
If hund = 1 Then
MakeWord = MakeWord & "cento"
Else
MakeWord = MakeWord & unitWord(hund) & "cento"
End If
End If
n = n - hund * 100
If n < 20 Then
ten = n
MakeWord = MakeWord & unitWord(ten) & ""
Else
ten = n \ 10
MakeWord = MakeWord & tenWord(ten) & ""
unit = n - ten * 10
MakeWord = Trim(MakeWord & unitWord(unit))
End If
MakeWord = Application.WorksheetFunction.Proper(Trim(MakeWord))
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top