Converting numbers to words (For Cheques)

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.
Who is Participating?
Geert GConnect With a Mentor Oracle dbaCommented:
this one does, but ... not free
Geert GOracle dbaCommented:
this component should do the trick
Whisper700Author Commented:

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
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Whisper700Author Commented:

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.
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
sorry ignore that. Just noticed it was not .net.
Geert GOracle dbaCommented:
VB code in Delphi Programming ?
Whisper700Author Commented:
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

Whisper700Author Commented:
Can't someone tell me how to use this dll found here with delphi?
my $.02

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

Geert GOracle dbaCommented:
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

Geert GOracle dbaCommented:
oops probably an error :

procedure SetCurrency; external Num2TextLib name 'SetCurrency';
Geert GOracle dbaCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.