Converting numbers to words (For Cheques)

Posted on 2008-10-27
Last Modified: 2013-11-23
I'm doing a cheque writer software. Everything so far is good. However, I need a function that converts numbers to english words. For example, 10,011 should be converted to ten thousand and eleven dollars...etc etc

I know there's an example on that illustrates what I want, but that example has some mistakes when placing commas and ands. I want a function that correctly converts numbers to english words including correct comma places and "and" places.

I'm using Delphi 2009.
Question by:Whisper700
  • 6
  • 4
  • 2
  • +1
LVL 37

Expert Comment

by:Geert Gruwez
ID: 22819370
this component should do the trick

Author Comment

ID: 22820023

I appreciate your help, but the file you gave megot me lost. It has more than 200 files in it and i didnt really know how to use it at all

Author Comment

ID: 22820081

I worked it out and im able to use that file now. But the problem is that it does not produce strings that are suitable for checks. For example, 10,000,003 was translated to TEN MILLION THREE. For cheques, a valid amount would be TEN MILLION AND THREE. The component you gave me does not include AND in the string of words.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

LVL 37

Accepted Solution

Geert Gruwez earned 210 total points
ID: 22820113
this one does, but ... not free

Expert Comment

ID: 22820124
Private Sub ConvertAmount(ByVal Amt As Integer)
        Millions = "ZERO"
        HundredThousands = "ZERO"
        TenThousands = "ZERO"
        Thousands = "ZERO"
        Hundreds = "ZERO"
        Tens = "ZERO"
        Units = "ZERO"

        Dim strAmt As String = Amt.ToString.Trim
        Dim CharVal As String = ""
        Dim UnitCount As Integer = 0
        Dim tmpWord As String = ""

        Do Until String.IsNullOrEmpty(strAmt)

            UnitCount += 1
            CharVal = Strings.Right(strAmt, 1)
            strAmt = Strings.Left(strAmt, Len(strAmt) - 1)

            tmpWord = GetWord(CharVal)

            Select Case UnitCount
                Case 1
                    Units = tmpWord
                Case 2
                    Tens = tmpWord
                Case 3
                    Hundreds = tmpWord
                Case 4
                    Thousands = tmpWord
                Case 5
                    TenThousands = tmpWord
                Case 6
                    HundredThousands = tmpWord
                Case 7
                    Millions = tmpWord

                Case Else

            End Select


    End Sub

    Private Function GetWord(ByVal CharVal As String) As String
        Dim strWord As String = ""
        Select Case CharVal
            Case "1"
                strWord = "ONE"
            Case "2"
                strWord = "TWO"
            Case "3"
                strWord = "THREE"
            Case "4"
                strWord = "FOUR"
            Case "5"
                strWord = "FIVE"
            Case "6"
                strWord = "SIX"
            Case "7"
                strWord = "SEVEN"
            Case "8"
                strWord = "EIGHT"
            Case "9"
                strWord = "NINE"
            Case "0"
                strWord = "ZERO"
            Case Else
                strWord = "*ZERO*"
        End Select

        GetWord = strWord
    End Function

Expert Comment

ID: 22820127
sorry ignore that. Just noticed it was not .net.
LVL 37

Expert Comment

by:Geert Gruwez
ID: 22820129
VB code in Delphi Programming ?

Author Comment

ID: 22824067
I'm not familiar with loading DLLS using delphi. Can you please show me an example of how to load and use that DLL provided in


Author Comment

ID: 22827743
Can't someone tell me how to use this dll found here with delphi?
LVL 45

Expert Comment

ID: 22855619
my $.02

The "AND" is supposed to separate the dollars from the cents.

LVL 37

Expert Comment

by:Geert Gruwez
ID: 22867819
sorry for nothing getting back to the Q rapidly

I tried several ways to get the dll working
Import ActiveX library
Import Type Library

manually using the dll with code (see snippet)

nothing worked,
now i'm still waiting on a return mail from the vendor ...

function TranslateNumber(str_Number: string; Lang: integer): string; stdcall;
procedure SetCurrency(str_Currency, str_CurrencyUnit, str_CurrencyPlural, str_CurrencyUnitPlural: string); stdcall;
const Num2TextLib = 'c:\windows\system32\DC_Num2Text10.dll';
function TranslateNumber; external Num2TextLib name 'TranslateNumber';
procedure SetCurrency; external Num2TextLib name 'TranslateNumber';

Open in new window

LVL 37

Expert Comment

by:Geert Gruwez
ID: 22867827
oops probably an error :

procedure SetCurrency; external Num2TextLib name 'SetCurrency';
LVL 37

Expert Comment

by:Geert Gruwez
ID: 22893425
hey man,
I got a response, kind of an ugly one :<

Dear Geert
we apologize , but this is a COM registeration problem , this is beyond our support.
please refer to delphi text books & web sites committee
Thank you
My GoldenSoft Support Team

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi XE10 Round Image 2 158
Delphi inherited method 6 76
I want to use librsync in my Delphi backup application. 3 59
RESTRequest Parameter 4 43
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question