convert the number to Arabic word

Discussion in 'Microsoft Access VBA Modules' started by Yousoft, Jun 15, 2009.

  1. Yousoft

    Yousoft Guest

    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
     
    Yousoft, Jun 15, 2009
    #1
    1. Advertisements

  2. On Mon, 15 Jun 2009 07:42:37 -0700, Yousoft
    <> wrote:

    >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.
    --

    John W. Vinson [MVP]
     
    John W. Vinson, Jun 15, 2009
    #2
    1. Advertisements

  3. Yousoft

    Yousoft Guest

    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



    "John W. Vinson" wrote:

    > On Mon, 15 Jun 2009 07:42:37 -0700, Yousoft
    > <> wrote:
    >
    > >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.
    > --
    >
    > John W. Vinson [MVP]
    >
     
    Yousoft, Jun 16, 2009
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tony

    Convert Hex to Number

    Tony, Jul 14, 2003, in forum: Microsoft Access VBA Modules
    Replies:
    1
    Views:
    1,964
    Tim Ferguson
    Jul 14, 2003
  2. Rick

    Checkbox - algorithm to convert n entries to a number

    Rick, Oct 21, 2003, in forum: Microsoft Access VBA Modules
    Replies:
    2
    Views:
    315
    John Vinson
    Oct 21, 2003
  3. Guest

    How do I convert a Hexidecimal number to Decimal

    Guest, Dec 3, 2004, in forum: Microsoft Access VBA Modules
    Replies:
    4
    Views:
    442
    Tim Ferguson
    Dec 3, 2004
  4. Guest

    i want to import arabic data from fox pro25 to access

    Guest, Jul 12, 2005, in forum: Microsoft Access VBA Modules
    Replies:
    2
    Views:
    198
    Omar Salem
    Mar 29, 2006
  5. Abdul

    Change Number to Arabic and back

    Abdul, Feb 26, 2007, in forum: Microsoft Access VBA Modules
    Replies:
    1
    Views:
    440
    GeoffG
    Feb 27, 2007
Loading...

Share This Page