
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)
- What IETF protocol is NetFlow associated with? Group of answer choices IPX/SPX IPIX HTTPS SSHarrow_forwardHow can I perform Laplace Transformation when using integration based on this?arrow_forwardWrite an example of a personal reflection of your course. - What you liked about the course. - What you didn’t like about the course. - Suggestions for improvement. Course: Information and Decision Sciences (IDS) The Reflection Paper should be 1 or 2 pages in length.arrow_forward
- using r languagearrow_forwardI need help in explaining how I can demonstrate how the Laplace & Inverse transformations behaves in MATLAB transformation (ex: LIke in graph or something else)arrow_forwardYou have made the Web solution with Node.js. please let me know what problems and benefits I would experience while making the Web solution here, as compared to any other Web solution you have developed in the past. what problems and benefits/things to keep in mind as someone just learningarrow_forward
- PHP is the server-side scripting language. MySQL is used with PHP to store all the data. EXPLAIN in details how to install and run the PHP/MySQL on your computer. List the issues and challenges I may encounter while making this set-up? why I asked: I currently have issues logging into http://localhost/phpmyadmin/ and I tried using the command prompt in administrator to reset the password but I got the error LOCALHOST PORT not found.arrow_forwardHTML defines content, CSS defines layout, and JavaScript adds logic to the website on the client side. EXPLAIN IN DETAIL USING an example.arrow_forwardusing r languangearrow_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



