
I get an error after entering the numbers though, "Attempted to divide by zero". What am I doing wrong and how do I fix this?
Forgot to post my code =/
Dim decAmountGiven As Decimal
Dim decPurchaseAmount As Decimal
Dim change As Decimal
If String.IsNullOrEmpty(txtAmountGiven.Text) Or String.IsNullOrEmpty(txtPurchaseAmount.Text) Then
MsgBox("Please enter a number")
ElseIf txtAmountGiven.Text < txtPurchaseAmount.Text Then
MsgBox("You have not given enough money")
Else
decAmountGiven = txtAmountGiven.Text
decPurchaseAmount = txtPurchaseAmount.Text
decAmountGiven = txtAmountGiven.Text
decPurchaseAmount = txtPurchaseAmount.Text
change = (decAmountGiven - decPurchaseAmount)
lblMoneyReturn.Text = change
lblDollarsOutput.Text = change \ 1
change = change Mod 1
lblQuartersOutput.Text = change \ 0.25
change = change Mod 0.25
lblDimesOutput.Text = change \ 0.1
change = change Mod 0.1
lblNickelsOutput.Text = change \ 0.05
change = change Mod 0.05
lblPenniesOutput.Text = change
End If

New Topic/Question
Reply




MultiQuote







|