Programming with Microsoft Visual Basic 2015 (MindTap Course List)
Programming with Microsoft Visual Basic 2015 (MindTap Course List)
7th Edition
ISBN: 9781285860268
Author: Diane Zak
Publisher: Cengage Learning
Question
Book Icon
Chapter 4.LC, Problem 2E
Program Plan Intro

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.

Expert Solution & Answer
Check Mark
Program Description Answer

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

Sample Output

Run the program, enter the date, number of Doughnuts and Muffins and then click on the “Calculate” button.

Screenshot of form

Programming with Microsoft Visual Basic 2015 (MindTap Course List), Chapter 4.LC, Problem 2E

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Specifications: Part-1Part-1: DescriptionIn this part of the lab you will build a single operation ALU. This ALU will implement a bitwise left rotation. Forthis lab assignment you are not allowed to use Digital's Arithmetic components.IF YOU ARE FOUND USING THEM, YOU WILL RECEIVE A ZERO FOR LAB2!The ALU you will be implementing consists of two 4-bit inputs (named inA and inB) and one 4-bit output (named out). Your ALU must rotate the bits in inA by the amount given by inB (i.e. 0-15).Part-1: User InterfaceYou are provided an interface file lab2_part1.dig; start Part-1 from this file.NOTE: You are not permitted to edit the content inside the dotted lines rectangle.Part-1: ExampleIn the figure above, the input values that we have selected to test are inA = {inA_3, inA_2, inA_1, inA_0} = {0, 1, 0,0} and inB = {inB_3, inB_2, inB_1, inB_0} = {0, 0, 1, 0}. Therefore, we must rotate the bus 0100 bitwise left by00102, or 2 in base 10, to get {0, 0, 0, 1}. Please note that a rotation left is…
How can I perform Laplace Transformation when using integration based on this? Where we convert time-based domain to frequency domain
what would be the best way I can explain the bevhoirs of Laplace and Inverse Transofrmation In MATLAB.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage