Introduction
The article describes an easy approach to converting a numeric dollar value into its text equivalent; the primary purpose for such a mechanism would be to express the amount displayed on a check as a string within the 'Amount' section typical to most checks. It may have some other use as well but that was the goal I had in mind when I wrote a simple code module to perform the conversion. The code provided in the example will convert numbers between 1 cent and $9,999,999.99 but it could be continued beyond this point with little additional effort.
To serve the purpose of a test harness, the sample application converts the numeric values into text and displays both in the form of a personal check. This application is not a full blown check writing application, it is just a demo project without any sort of back end record keeping system whatsoever.

Figure 1: Demo Application Displaying converted numeric values as text
Getting Started:
Unzip the attached file; in it you will find solution containing a single windows forms project. The project was written in Visual Basic 2005 and it contains only two significant files, a code module entitled, "DecimalToText" and a form class entitled, "frmCheck". The module is used to perform the string conversion functions while the form class is used as a test harness that serves only to evaluate the code module.

Figure 2. Check Writer Solution in the Solution Explorer
There are certainly many other options available for constructing code to perform such a translation, however, in a effort to keep things simple, I opted to convert the numeric value into a character array and to use a series of select case statements to determine the length of the array and to set portions of the text according to the length and content of the amount entered as a numeric value. In this instance, I found that the select case statement approach used did offer more complete control over writing out the text given the current numeric value's content in terms of applying the correct text at the correct time to render out the correct amount string at the end of the processing task. Still and all, the approach shown is not a terribly efficient way of handling the translation but it does appear to work well enough across the involved range of potential numeric values.
The Code: DecimalToText Module
As was mentioned, this class was declared as a module to make its functions accessible throughout the application without the requiring the creation of an instance of the class. This class contains only one public function, "ConvertDecimalToText"; the method accepts a decimal value as its only argument. All other functions or subroutines in the class are declared private and are only called by this public function.
The class itself does not include any import statements nor does it inherit from any other class or implement any interfaces. The ConvertDecimalToText function accepts the decimal value to translate into text and in order to determine the size number of places in the decimal value, the value is converted to a string and then into a character array. The character array is stripped of the fractional portion of the number and its decimal place, the length of the remaining array is evaluated within a select statement in order to determine the type of number to process (ones, tens, hundreds, thousands, etc.). Once the size of the number has been determined, the value is processed into text by values acquired from the character array passed into a collection of other functions used to retrieve the appropriate text for that value. In some instances, to properly write out the text, either one or two values from the character array are joined together and processed (so that the function can return, for example, ninety-nine instead of ninety and nine).
The code used in this function is as follows:
Public Function ConvertDecimalToText(ByVal decAmount As Decimal) As String
Dim strAmount As String = ""
Dim decValue As Decimal = decAmount
Dim amount() As Char
amount = decValue.ToString.ToCharArray()
Dim places As Integer
places = amount.Length - 3
If amount(0) = "0" Then
places = places - 1
End If
Select Case places
Case 0
'change only
strAmount = "Zero " & GetChange(amount)
Case 1
'dollar
strAmount = GetDollars(amount(0)) & GetChange(amount)
Case 2
'tens of dollars
Dim strTemp As String = amount(0) & amount(1)
strAmount = GetTensOfDollars(strTemp) & GetChange(amount)
Case 3
'hundreds of dollars
Dim strTemp As String = amount(1) & amount(2)
strAmount = GetHundredsOfDollars(amount(0)) &
GetTensOfDollars(strTemp) & GetChange(amount)
Case 4
'thousands of dollars
Dim strTemp10s As String = amount(2) & amount(3)
strAmount = GetThousandsOfDollars(amount(0)) &
GetHundredsOfDollars(amount(1)) & GetTensOfDollars(strTemp10s) &
GetChange(amount)
Case 5
'tens of thousands of dollars
Dim strTemp1000s As String = amount(0) & amount(1)
Dim strTemp10s As String = amount(3) & amount(4)
strAmount = GetTenThousandsOfDollars(strTemp1000s) &
GetHundredsOfDollars(amount(2)) & GetTensOfDollars(strTemp10s) &
GetChange(amount)
Case 6
'hundreds of thousands of dollars
Dim strTemp1000s As String = amount(1) & amount(2)
Dim strTemp10s As String = amount(4) & amount(5)
If amount(1) = "0" And amount(2) = "0" Then
strAmount = Get100ThousandsOfDollars(amount(0), True) &
GetTenThousandsOfDollars(strTemp1000s) & GetHundredsOfDollars(amount(3)) & GetTensOfDollars(strTemp10s) & GetChange(amount)
Else
strAmount = Get100ThousandsOfDollars(amount(0), false) &
GetTenThousandsOfDollars(strTemp1000s) &
GetHundredsOfDollars(amount(3)) & GetTensOfDollars(strTemp10s) &
GetChange(amount)
End If
Case 7
'one million dollars
Dim strTempMillions As String = amount(0)
Dim strTemp1000s As String = amount(2) & amount(3)
Dim strTemp10s As String = amount(5) & amount(6)

Comments
Join the conversation! Your thoughts help the community grow.