My problem comes in when the program wants you to count how many dollars, quarters, dimes, and pennies are due from this change. :confused:
Can someone please help me with this? I don't know where to put my variables to make the computer compute this. :o
Here is my code. P.S. It doesn't work!
Expand|Select|Wrap|Line Numbers
- Private Sub uiCalButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uiCalButton.Click
- 'declare variables
- Dim amountOwed, amountPaid, changeDue As Decimal
- Const dollar As Decimal = 1D
- Const quarters As Decimal = 0.25D
- Const dimes As Decimal = 0.1D
- Const nickels As Decimal = 0.05D
- Const pennies As Decimal = 0.01D
- Dim dollarChange As Integer
- Dim quarterChange As Integer
- Dim dimeChange As Integer
- Dim nickelChange As Integer
- Dim pennyChange As Integer
- 'assign value to variables
- amountOwed = Decimal.Parse(Me.uiOwedTextBox.Text)
- amountPaid = Decimal.Parse(Me.uiPaidTextBox.Text)
- 'perform calculations
- changeDue = amountPaid - amountOwed
- dollarChange = Convert.ToInt32(changeDue) \ 100
- quarterChange = Convert.ToInt32(changeDue) \ 25
- dimeChange = Convert.ToInt32(changeDue) \ 10
- nickelChange = Convert.ToInt32(changeDue) \ 5
- pennyChange = Convert.ToInt32(changeDue) \ 1
- 'display total amounts in controls
- Me.uiChangeLabel.Text = Convert.ToString(changeDue)
- Me.uiDollarLabel.Text = Convert.ToString(dollarChange)
- Me.uiQuarterLabel.Text = Convert.ToString(quarterChange)
- Me.uiDimeLabel.Text = Convert.ToString(dimeChange)
- Me.uiNickelLabel.Text = Convert.ToString(nickelChange)
- Me.uiPennyLabel.Text = Convert.ToString(pennyChange)
- Me.uiChangeLabel.Text = Format(changeDue, "currency")
- 'send focus to the clear form
- Me.uiClearForm.Focus()
- End Sub