Q:

Stop Rounding When Converting Numbers to Words

I'm working on a project that converts money values into words. I've found some code that helps me with this conversion (as well as implementing some pieces from a previous question) and the code works fine and does what I need of it...BUT the problem I'm getting is that Visual Basic keeps rounding up my TEXT conversion.
I originally had my variables as Doubles, read that Decimals tend to keep the values and moved everything to Decimal, but it's still converting my words up by one. I've also tried to remove the decimal place before any conversion still happens but the text words still get the round up. For example, if I input 14,508.85 in my check, the text conversion spits out "Fourteen Thousand Five Hundred Nine and 85/100"
Stepping through the program, it looks like the value is being changed with the Modulus call in the hundredsConvert function. Mod is a requirement of the program (class project). Is there something I'm missing maybe? imgur.com/Nrym9qy
Thanks for any help!
The code follows
    Public Class Check

    Dim checkValue As Decimal
    Dim tempValue As Decimal
    Dim result As String = ""
    Dim temp As Decimal
    Dim change As String = ""
    Dim tempString As String = ""
    Dim tempChange As Decimal

    Private Function hundredsConvert(ByVal num As Decimal) As String

        Static teens() As String = {"Zero", "One",
        "Two", "Three", "Four", "Five", "Six", "Seven",
        "Eight", "Nine", "Ten", "Eleven", "Twelve",
        "Thirteen", "Fourteen", "Fifteen", "Sixteen",
        "Seventeen", "Eightteen", "Nineteen"}
        Static tens() As String = {"Twenty",
        "Thirty", "Forty", "Fifty", "Sixty", "Seventy",
        "Eighty", "Ninety"}

        ' If the number is 0, return an empty string.
        If num = 0 Then Return ""

        ' Handle the hundreds digit.
        Dim digit As Decimal
        Dim result As String = ""
        If num > 99 Then
            digit = num \ 100
            num = num Mod 100
            result = teens(digit) & " Hundred"
        End If

        ' If num = 0, we have hundreds only.
        If num = 0 Then Return result.Trim()

        ' See if the rest is less than 20.
        If num < 20 Then
            ' Look up the correct name.
            result &= " " & teens(num)
        Else
            ' Handle the tens digit.
            digit = num \ 10
            num = num Mod 10
            result &= " " & tens(digit - 2)

            ' Handle the final digit.
            If num > 0 Then
                result &= " " & teens(num)
            End If
        End If

        Return result.Trim()

    End Function

    Private Function numToString(ByVal num As Decimal) As String
        'Get the change'
        change = num.ToString
        change = change.Substring(change.IndexOf(".") + 1) + "/100"

        tempString = num.ToString
        tempString.Remove(tempString.IndexOf(".") + 2)
        num = Decimal.Parse(tempString)

        Static groups() As String = {" ", "Thousand ", "Million",
            "Billion", "Trillion", "Quadrillion", "?", "??",
            "???", "????"}
        Dim result As String = ""

        'Process the groups, smallest first.'
        Dim quotient As Decimal
        Dim remainder As Decimal
        Dim group_num As Decimal = 0
        Do While num > 0
            'Get the next group of three digits.'
            quotient = num \ 1000
            remainder = num Mod 1000
            num = quotient

            'Convert the group into words.'
            result = hundredsConvert(remainder) &
                " " & groups(group_num) &
                result

            'Get ready for the next group.'
            group_num += 1
        Loop

        'Remove the trailing ", ".
        If result.EndsWith(", ") Then
            result = result.Substring(0, result.Length - 2)
        End If

        Return result
    End Function

    Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
        'Dim declarations'

        'Convert check value from a text field to a double'
        Try
            checkValue = txtCheckAmount.Text
        Catch ex As InvalidCastException
            MessageBox.Show("You must enter a numbers to write a check.")

        End Try

        lblWrittenDollars.Text = numToString(checkValue) & "and " & change

        If checkValue = 0 Then
            MessageBox.Show("You must have some value in order to write a check.")
            txtCheckAmount.Clear()
            lblWrittenDollars.Text = ""
        Else
            Dim finalize = MessageBox.Show("You have specified that you want to write a check for " & checkValue & "?", "", MessageBoxButtons.YesNo)
            If finalize = DialogResult.No Then
                txtCheckAmount.Clear()
                lblWrittenDollars.Text = ""

            ElseIf finalize = DialogResult.Yes Then
            End If
        End If

        checkValue = 0

    End Sub

    Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click

    End Sub

    Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub

    Private Sub txtPayOrderTo_TextChanged(sender As Object, e As EventArgs) Handles txtPayOrderTo.TextChanged

    End Sub

End Class

A:

Make sure, in this case, that you call Math.Floor on your decimal value before the call to mod.  This will, for non-negative values, give you just the rounded-down integer portion of your decimal, allowing you to convert it into text.  Best of luck!

