We have some quantity of eggs to sell. We want to package it by the dozen. We want find how many dozen we can sell and how many we will have left over.
Build the form as shown below:
Horizonal Scroll Bar
Name: HsbEggs
LargeChange = 1
Labels
Name: LblInstructions
Text = "Select the number of eggs:"
Name: LblEggs
Text: "0"
Name: LblDozen
Text: "Dozen=0"
Name: LblRemainder
Text: "Remainder=0"
Write the code as shown below:
'Programmer: Janet Joy
'Select number of eggs and show the number of dozen andremaining
Public Class Form1
Private Sub HsbEggs_Scroll(sender As Object, e As ScrollEventArgs) Handles HsbEggs.Scroll
'Calculate dozen and number left fro mvalue on scroll bar
Dim eggs As Integer = Me.HsbEggs.Value
Me.LblEggs.Text = eggs
Dim dozen As Integer = eggs \ 12
Me.LblDozen.Text = "Dozen=" & dozen
Dim remain As Integer = eggs Mod 12
Me.LblRemainder.Text = "Remainder=" & remain
End Sub
End Class
Remember, you should try doing each of these programs on your own. Get it to work, break it, modify it, and then try to write it on your own!