convert the number to Arabic word

  • Thread starter Thread starter Yousoft
  • Start date Start date
Y

Yousoft

I prepared module for spellnumber to convert the number to Arabic words, so
when I view the module It is showing me unreadable letter in report or
query,. Please help
thanks
 
I prepared module for spellnumber to convert the number to Arabic words, so
when I view the module It is showing me unreadable letter in report or
query,. Please help
thanks
Please post your code and the actual error message.
 
Function SpellNumber(ByVal MyNumber)
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count

ReDim Place(9) As String
Place(2) = " Ãáà "
Place(3) = " ãáíæä "
Place(4) = " Billion "
Place(5) = " Trillion "

' String representation of amount
MyNumber = Trim(Str(MyNumber))

' Position of decimal place 0 if none
DecimalPlace = InStr(MyNumber, ".")
'Convert cents and set MyNumber to dollar amount
If DecimalPlace > 0 Then
Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & "00", 2))
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
End If

Count = 1
Do While MyNumber <> ""
Temp = GetHundreds(Right(MyNumber, 3))
If Temp <> "" And Len(MyNumber) > 3 Then
Dollars = "æ " & Temp & Place(Count) & Dollars
ElseIf Temp <> "" And Len(MyNumber) <= 3 Then
Dollars = Temp & Place(Count) & Dollars
End If
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop

Select Case Dollars
Case ""
Dollars = "ÕÃÑ ÃÑåã "
Case "One"
Dollars = "ÃÑåã æÇÃà æ"
Case Else
Dollars = Dollars & " ÃÑåã "
End Select

Select Case Cents
Case ""
Cents = " æ ÕÃÑ ÃáÓ "
Case "One"
Cents = " æ ÃáÓ æÇÃà "
Case Else
'Cents = " æ " & Cents & " ÃáÓ "
Cents = " æ " & Cents & " ÃáÓ "
End Select

SpellNumber = Dollars & Cents
End Function

'*******************************************
' Converts a number from 100-999 into text *
'*******************************************
Function GetHundreds(ByVal MyNumber)
Dim Result As String

If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)

'Convert the hundreds place
If Mid(MyNumber, 2, 2) <> "00" Then
Select Case Mid(MyNumber, 1, 1)
Case "0"
Result = Result
Case "1"
Result = " ãÇÆÉ æ "
Case "2"
Result = " ãÆÊÇä æ "
Case Else
Result = GetDigit(Mid(MyNumber, 1, 1)) & " ãÇÆÉ æ "
End Select
Else
Select Case Mid(MyNumber, 1, 1)
Case "0"
Result = Result
Case "1"
Result = " ãÇÆÉ "
Case "2"
Result = " ãÆÊÇä "
Case Else
Result = GetDigit(Mid(MyNumber, 1, 1)) & " ãÇÆÉ "
End Select
End If
'-------------------------
' If Mid(MyNumber, 1, 1) = "1" Then
' Result = " ãÇÆÉ "
' ElseIf Mid(MyNumber, 1, 1) <> "0" Then
' Result = GetDigit(Mid(MyNumber, 1, 1)) & " ãÇÆÉ "
' End If


'Convert the tens and ones place
If Mid(MyNumber, 2, 1) <> "0" Then
Result = Result & GetTens(Mid(MyNumber, 2))
Else
Result = Result & GetDigit(Mid(MyNumber, 3))
End If

'-------------------------------------
' If Mid(MyNumber, 2, 1) <> "0" Then
' Result = Result & GetTens(Mid(MyNumber, 2))
' Else
' Result = Result & " æ " & GetDigit(Mid(MyNumber, 3))
' End If


GetHundreds = Result
End Function

'*********************************************
' Converts a number from 10 to 99 into text. *
'*********************************************
Function GetTens(TensText)
Dim Result As String

Result = "" 'null out the temporary function value
If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19
Select Case Val(TensText)
Case 10: Result = "ÚÔÑÉ"
Case 11: Result = "ÃÃà ÚÔÑÉ"
Case 12: Result = "ÅËäÇ ÚÔÑÉ"
Case 13: Result = "ËáÇËÉ ÚÔÑÉ"
Case 14: Result = "ÃÑÈÚÉ ÚÔÑÉ"
Case 15: Result = "ÎãÓÉ ÚÔÑÉ"
Case 16: Result = "ÓÊÉ ÚÔÑÉ"
Case 17: Result = "ÓÈÚÉ ÚÔÑÉ"
Case 18: Result = "ËãÇäíÉ ÚÔÑÉ"
Case 19: Result = "ÊÓÚÉ ÚÔÑÉ"
Case Else
End Select
Else ' If value between 20-99
Select Case Val(Left(TensText, 1))
Case 2: Result = "ÚÔÑæä "
Case 3: Result = "臂辊 "
Case 4: Result = "ÇÑÈÚæä "
Case 5: Result = "ÎãÓæä "
Case 6: Result = "ÓÊæä "
Case 7: Result = "ÓÈÚæä "
Case 8: Result = "ËãÇäæä "
Case 9: Result = "ÊÓÚæä "
Case Else
End Select
Dim r
r = ""
r = GetDigit(Right(TensText, 1))
If Val(Left(TensText, 1)) = 0 Then
Result = r & Result
Else
If r <> "" Then
Result = r & " æ " & Result 'Retrieve ones place
Else
Result = Result
End If
End If
End If
GetTens = Result
End Function

'*******************************************
' Converts a number from 1 to 9 into text. *
'*******************************************
Function GetDigit(Digit)
Select Case Val(Digit)
Case 1: GetDigit = "æÇÃÃ"
Case 2: GetDigit = "ÅËäÇä"
Case 3: GetDigit = "ËáÇËÉ"
Case 4: GetDigit = "ÃÑÈÚÉ"
Case 5: GetDigit = "ÎãÓÉ"
Case 6: GetDigit = "ÓÊÉ"
Case 7: GetDigit = "ÓÈÚÉ"
Case 8: GetDigit = "ËãÇäíÉ"
Case 9: GetDigit = "ÊÓÚÉ"
Case Else: GetDigit = ""
End Select
End Function
 
Back
Top