Your problem is the use of the / operator and your Convert.ToInt32. When the resulting value is a fractional number greater or equal to .5, it rounds up. Put Math.Floor around your divides to stop this, i.e.
intDollars = Convert.ToInt32(Math.Floor(decChange / intDOLLARS_VALUE))
. Saves you all the Mod code, too.
Momerath
Nearly a Senior Poster
3,386 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558
I would do everything in pennies. That is, if the input values are (for example) $250 and $127.93, I would convert that to 25000 and 12793 and go from there. That eliminates rounding when you use "\" to extract each denomination.
'provide your own input validation first
Dim cost As Integer = 100 * CDbl(txtCost.Text)
Dim paid As Integer = 100 * CDbl(txtPaid.Text)
.
.
.
Reverend Jim
Posting Shark
1,169 posts since Aug 2010
Reputation Points: 253
Solved Threads: 159