MOD+Operator


 * Divides two numbers and returns only the remainder.**

number1 Mod number2

Dim testResult As Double testResult = 10 Mod 5 testResult = 10 Mod 3 testResult = 12 Mod 4.3 testResult = 12.6 Mod 5 testResult = 47.9 Mod 9.35
 * What is the remainder when 10/5?**
 * What is the remainder when 10/3?**
 * What is the remainder when 12/4.3?**
 * What is the remainder when 12.6/5?**
 * What is the remainder when 47.9/9.35?**

The expressions in the preceding example return values of 0, 1, 3.4, 2.6, and 1.15. Public Class Form1 Dim decChangeToGive As Decimal Private Sub cmdMakeChange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMakeChange.Click

decChangeToGive = (txtAmountGiven.Text - txtOwed.Text) * 100
 * Calculating the change required to give back.**

Dim intFives As Integer = decChangeToGive \ 500 decChangeToGive = decChangeToGive Mod 500
 * Calculating how many types of each monetary value are required to return to the customer.**

Dim intToonies As Integer = decChangeToGive \ 200 decChangeToGive = decChangeToGive Mod 200

Dim intLoonies As Decimal = decChangeToGive \ 100 decChangeToGive = decChangeToGive Mod 100

Dim intQuarter As Decimal = decChangeToGive \ 25 decChangeToGive = decChangeToGive Mod 25

Dim intDimes As Decimal = decChangeToGive \ 10 decChangeToGive = decChangeToGive Mod 10

Dim intPennies As Decimal = decChangeToGive \ 1 decChangeToGive = decChangeToGive Mod 1

lblResponse.Text = "You need to give: " & intFives & " fives, " & intToonies & " toonies, " & intLoonies & " loonies and " & intQuarter & " quarters " & intDimes & " dimes " & intPennies & " pennies. "
 * Spitting out to the user the amount of each of the monetary amounts.**

End Sub

End Class