人気ブログランキング | 話題のタグを見る

How Can You Fix - Converting number to words?

Converting number to words

I would like to convert number with three decimals places to words.
Is there a macro available?
Please help to convert Bahrain Dinar currency number to words as it has three digit decimal places.
 
Suresh AK

Keys to the Problem Converting number to words

Download SmartPCFixer for Free Now

O.K.
 
Here is a very quick update.  I have not tested it thoroughly.  I have not changed the comments in the code. 
It is only a starting point.  Let me know what you think:
 
 
Option Explicit
'Main Function
Function SpellNumber(ByVal MyNumber)
    Dim Dollars, Cents, Temp
    Dim DecimalPlace, Count
    ReDim Place(9) As String
    Place(2) = " Thousand "
    Place(3) = " Million "
    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 = GetHundreds(Left(Mid(MyNumber, DecimalPlace + 1) & _
                  "00", 3))
        MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
    End If
    Count = 1
    Do While MyNumber <> ""
        Temp = GetHundreds(Right(MyNumber, 3))
        If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
        If Len(MyNumber) > 3 Then
            MyNumber = Left(MyNumber, Len(MyNumber) - 3)
        Else
            MyNumber = ""
        End If
        Count = Count + 1
    Loop
    Select Case Dollars
        Case ""
            Dollars = "Bahiraini Dinars Zero"
        Case "One"
            Dollars = "Bahiraini Dinar One"
         Case Else
            Dollars = "Bahiraini Dinars " & Dollars
    End Select
    Select Case Cents
        Case ""
            Cents = " and No Fils"
        Case "One"
            Cents = " and One Fil"
              Case Else
            Cents = " and " & Cents & " Fils"
    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, 1, 1) <> "0" Then
        Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "
    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
    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 = "Ten"
            Case 11: Result = "Eleven"
            Case 12: Result = "Twelve"
            Case 13: Result = "Thirteen"
            Case 14: Result = "Fourteen"
            Case 15: Result = "Fifteen"
            Case 16: Result = "Sixteen"
            Case 17: Result = "Seventeen"
            Case 18: Result = "Eighteen"
            Case 19: Result = "Nineteen"
            Case Else
        End Select
    Else                                 ' If value between 20-99...
        Select Case Val(Left(TensText, 1))
            Case 2: Result = "Twenty "
            Case 3: Result = "Thirty "
            Case 4: Result = "Forty "
            Case 5: Result = "Fifty "
            Case 6: Result = "Sixty "
            Case 7: Result = "Seventy "
            Case 8: Result = "Eighty "
            Case 9: Result = "Ninety "
            Case Else
        End Select
        Result = Result & GetDigit _
            (Right(TensText, 1))  ' Retrieve ones place.
    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 = "One"
        Case 2: GetDigit = "Two"
        Case 3: GetDigit = "Three"
        Case 4: GetDigit = "Four"
        Case 5: GetDigit = "Five"
        Case 6: GetDigit = "Six"
        Case 7: GetDigit = "Seven"
        Case 8: GetDigit = "Eight"
        Case 9: GetDigit = "Nine"
        Case Else: GetDigit = ""
    End Select
End Function

Boot in Safe Mode:

  • Open Run command as previously described
  • Type MSConfig
  • Click on Boot tab
  • Tick Safe boot in Boot option
  • Select Network
  • Click Apply and OK
  • Reboot your system

Your system will boot in Safe mode with Networking. You may now try and open Windows Store and should not see any errors.

Recommended Method to Repair the Problem: Converting number to words:

How to Fix Converting number to words with SmartPCFixer?

1. Click the button to download Error Fixer . Install it on your system.  Open it, and it will perform a scan for your system. The junk files will be shown in the list.

2. After the scan is finished, you can see the errors and problems need to be fixed. Click Fix All.

3. When the Fixing part is finished, your computer has been speeded up and the errors have been fixed


Related: Can't Get Admin. Tools To Work In Windows 7, Except Config.sys,Can't Delete Messages In My Deleted Items Folder,Can You Print From Web Browser In Home Netwrek With Windows 8 Or 7 Whitout Having A Server Installed?,Can You Create A Form From A Report? Arghh I Hope So!,Can't Delete A Link In Favorites (Vista IE9),Changing FONT Size On Labels (Office Starter 2010 / Windows 7 ),Chrome Browsers Windows Incorrectly Reported To Be Open,Certificate Error - Cannot Open Adobe Files To Read Unless I Purchase Adobe Professional,Cgi Extensions,Cant See Small Windows Above My Task Bar When I Move The Mouse Over The Explorer Icon In The Task Bar Anymore,Computer Sleeps Immediately Upon Wakeup From Hibernation,Computer Locks On Me And Only Ctrl + Alt + Delete Restores It After Lock Up,Computer Restarts When I Put My Admin Password,Conditional Formatting Highlight Cells If A Date Falls Within A Given Week,Computer Does Not Shut Down When Turning It Off.
Read More: Fast Solution to Error: constant random freezing and re booting,[Solved] Convert text format,[Solved] control panel folder opens up empty,Tech Support: Continous runing of video clips,Troubleshoot:Convert a column of numbers into Alphabet characters Error,chkdsk cannot continue in read-only mode.,Citrix Go To Meeting Downloader,Changing the range of a named range,Conditional Format Problem...,Connect to my network but no access to internet
by HowToFixJava66 | 2016-09-23 17:30