
Bakery application
Program plan:
- Create new Windows Forms Application.
- Design the form by placing the labels, textbox, and button and then change their name and properties.
- Inside the “Calculate” button,
- Declare required variables.
- Assign the name to the variables.
- Calculate the items sold.
- Calculate the sub total
- Calculate the sales tax.
- Display total amounts.
- Display tax and sales clerk’s name.
- Inside the “Exit” button,
- Close the form.
- Inside the “btnPrint_Click”
- Print the sales receipt.
- Inside the “txtDate_Enter”
- Select all the values.
- Inside the “txtDate_keyPress”,
- Check the condition.
- Inside the “txtDonuts_Enter”,
- Select all the text.
- Inside the “CancelKeys”,
- Check the condition.
- Inside the “txtMuffins_Enter”,
- Select all the text.

This program is to modify the bakery application.
Explanation of Solution
Program:
'Definition of class frmMain
Public Class frmMain
'Definition of button calculate
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
' Calculate number of items sold and total sales
Const PromtMsg As String = "Salesclerk's name:"
Const title As String = "Name Entry"
Const ItemPrice As Decimal = 0.5D
Const tax As Decimal = 0.02D
Dim donuts As Integer
Dim muffins As Integer
Dim totalItems As Integer
Dim subTotal As Decimal
Dim salesTax As Decimal
Dim totalSales As Decimal
Static clerk As String
'Assign the name to variable
clerk = InputBox(PromtMsg, title, clerk)
' Calualte the items sold
Integer.TryParse(txtDonuts.Text, donuts)
Integer.TryParse(txtMuffins.Text, muffins)
totalItems = donuts + muffins
' calculate the subtotal
subTotal = totalItems * ItemPrice
' calculate the sales tax
salesTax = subTotal * tax
' calculate the total sales
totalSales = subTotal + salesTax
' display total amounts
lblTotalItems.Text = Convert.ToString(totalItems)
lblTotalSales.Text = totalSales.ToString("C2")
' display tax and salesclerk's name
lblMsg.Text = "The sales tax was " &
salesTax.ToString("C2") & "." &
ControlChars.NewLine & clerk
End Sub
'Definition of button clear
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
'Assign text box to empty
txtDonuts.Text = String.Empty
txtMuffins.Text = String.Empty
lblTotalItems.Text = String.Empty
lblTotalSales.Text = String.Empty
lblMsg.Text = String.Empty
' send the focus to the Doughnuts box
txtDonuts.Focus()
End Sub
'Definition of button exit
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
'Close the form
Me.Close()
End Sub
'Definition of button print
Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click
'print the sales receipt
btnCalc.Visible = False
btnClear.Visible = False
btnExit.Visible = False
btnPrint.Visible = False
PrintForm1.Print()
btnCalc.Visible = True
btnClear.Visible = True
btnExit.Visible = True
btnPrint.Visible = True
End Sub
'Definition of ClearLabels
Private Sub ClearLabels(sender As Object, e As EventArgs) _
Handles txtDonuts.TextChanged, txtMuffins.TextChanged
' Clear the total items, total sales, and message
lblTotalItems.Text = String.Empty
lblTotalSales.Text = String.Empty
lblMsg.Text = String.Empty
End Sub
'Definition of txtDate_Enter
Private Sub txtDate_Enter(sender As Object, e As EventArgs) Handles txtDate.Enter
'Select all the values
txtDate.SelectAll()
End Sub
'Defintion of txtDate_keyPress
Private Sub txtDate_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtDate.KeyPress
'Check the conditon
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso
e.KeyChar <> "/" AndAlso e.KeyChar <> "-" AndAlso
e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
'Definition of txtDonuts_Enter
Private Sub txtDonuts_Enter(sender As Object, e As EventArgs) Handles txtDonuts.Enter
'Select all the text
txtDonuts.SelectAll()
End Sub
'Defintion of CancelKeys
Private Sub CancelKeys(sender As Object, e As KeyPressEventArgs) Handles txtDonuts.KeyPress, txtMuffins.KeyPress
'Check the condition
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
'Definition of txtMuffins_Enter
Private Sub txtMuffins_Enter(sender As Object, e As EventArgs) Handles txtMuffins.Enter
'Select all the text
txtMuffins.SelectAll()
End Sub
End Class
Run the program, enter the date, number of Doughnuts and Muffins and then click on the “Calculate” button.
Screenshot of form
Want to see more full solutions like this?
Chapter 4 Solutions
Programming with Microsoft Visual Basic 2015 (MindTap Course List)
- Describe three (3) Multiplexing techniques common for fiber optic linksarrow_forwardCould you help me to know features of the following concepts: - commercial CA - memory integrity - WMI filterarrow_forwardBriefly describe the issues involved in using ATM technology in Local Area Networksarrow_forward
- For this question you will perform two levels of quicksort on an array containing these numbers: 59 41 61 73 43 57 50 13 96 88 42 77 27 95 32 89 In the first blank, enter the array contents after the top level partition. In the second blank, enter the array contents after one more partition of the left-hand subarray resulting from the first partition. In the third blank, enter the array contents after one more partition of the right-hand subarray resulting from the first partition. Print the numbers with a single space between them. Use the algorithm we covered in class, in which the first element of the subarray is the partition value. Question 1 options: Blank # 1 Blank # 2 Blank # 3arrow_forward1. Transform the E-R diagram into a set of relations. Country_of Agent ID Agent H Holds Is_Reponsible_for Consignment Number $ Value May Contain Consignment Transports Container Destination Ф R Goes Off Container Number Size Vessel Voyage Registry Vessel ID Voyage_ID Tonnagearrow_forwardI want to solve 13.2 using matlab please helparrow_forward
- a) Show a possible trace of the OSPF algorithm for computing the routing table in Router 2 forthis network.b) Show the messages used by RIP to compute routing tables.arrow_forwardusing r language to answer question 4 Question 4: Obtain a 95% standard normal bootstrap confidence interval, a 95% basic bootstrap confidence interval, and a percentile confidence interval for the ρb12 in Question 3.arrow_forwardusing r language to answer question 4. Question 4: Obtain a 95% standard normal bootstrap confidence interval, a 95% basic bootstrap confidence interval, and a percentile confidence interval for the ρb12 in Question 3.arrow_forward
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage



