Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' Name: Bakery Project
- ' Purpose: Calculates the total number of
- ' items sold and the total sales
- ' Programmer: <your name> on <current date>
- Option Explicit On
- Option Infer Off
- Option Strict On
- Public Class frmMain
- Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
- ' calculate number of items sold and total sales
- Const decITEM_PRICE As Decimal = 0.5D
- Const decTAX_RATE As Decimal = 0.02D
- Dim intDonuts As Integer
- Dim intMuffins As Integer
- Dim intTotalItems As Integer
- Dim decSubtotal As Decimal
- Dim decSalesTax As Decimal
- Dim decTotalSales As Decimal
- Dim strClerk As String
- Const strTitle As String = "Saleclerk's name"
- Const strPrompt As String = "Name Entry"
- strClerk = InputBox(strPrompt, strTitle)
- Integer.TryParse(txtDonuts.Text, intDonuts)
- Integer.TryParse(txtMuffins.Text, intMuffins)
- intTotalItems = intDonuts + intMuffins
- decSubtotal = intTotalItems * decITEM_PRICE
- decSalesTax = decSubtotal * decTAX_RATE
- decTotalSales = decSubtotal + decSalesTax
- lblTotalItems.Text = intTotalItems.ToString("C2")
- lblTotalSales.Text = decTotalSales.ToString("C2")
- lblMsg.Text = "The sales tax was " & decSalesTax.ToString("C2") & "." & ControlChars.NewLine & strClerk
- End Sub
- Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
- ' prepare screen for the next sale
- 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
- Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
- Me.Close()
- End Sub
- 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
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement