Advertisement
Guest User

ok

a guest
Feb 22nd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' Name:         Bakery Project
  2. ' Purpose:      Calculates the total number of
  3. '               items sold and the total sales
  4. ' Programmer:   <your name> on <current date>
  5.  
  6. Option Explicit On
  7. Option Infer Off
  8. Option Strict On
  9.  
  10. Public Class frmMain
  11.     Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
  12.         ' calculate number of items sold and total sales
  13.  
  14.         Const decITEM_PRICE As Decimal = 0.5D
  15.         Const decTAX_RATE As Decimal = 0.02D
  16.  
  17.         Dim intDonuts As Integer
  18.         Dim intMuffins As Integer
  19.         Dim intTotalItems As Integer
  20.         Dim decSubtotal As Decimal
  21.         Dim decSalesTax As Decimal
  22.         Dim decTotalSales As Decimal
  23.         Dim strClerk As String
  24.  
  25.         Const strTitle As String = "Saleclerk's name"
  26.         Const strPrompt As String = "Name Entry"
  27.  
  28.         strClerk = InputBox(strPrompt, strTitle)
  29.  
  30.         Integer.TryParse(txtDonuts.Text, intDonuts)
  31.         Integer.TryParse(txtMuffins.Text, intMuffins)
  32.  
  33.         intTotalItems = intDonuts + intMuffins
  34.         decSubtotal = intTotalItems * decITEM_PRICE
  35.         decSalesTax = decSubtotal * decTAX_RATE
  36.  
  37.         decTotalSales = decSubtotal + decSalesTax
  38.  
  39.         lblTotalItems.Text = intTotalItems.ToString("C2")
  40.         lblTotalSales.Text = decTotalSales.ToString("C2")
  41.  
  42.         lblMsg.Text = "The sales tax was " & decSalesTax.ToString("C2") & "." & ControlChars.NewLine & strClerk
  43.     End Sub
  44.  
  45.     Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
  46.         ' prepare screen for the next sale
  47.  
  48.         txtDonuts.Text = String.Empty
  49.         txtMuffins.Text = String.Empty
  50.         lblTotalItems.Text = String.Empty
  51.         lblTotalSales.Text = String.Empty
  52.         lblMsg.Text = String.Empty
  53.         ' send the focus to the Doughnuts box
  54.        txtDonuts.Focus()
  55.  
  56.     End Sub
  57.  
  58.     Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
  59.         Me.Close()
  60.     End Sub
  61.  
  62.     Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click
  63.         ' print the sales receipt
  64.  
  65.         btnCalc.Visible = False
  66.         btnClear.Visible = False
  67.         btnExit.Visible = False
  68.         btnPrint.Visible = False
  69.         'PrintForm1.Print()
  70.        btnCalc.Visible = True
  71.         btnClear.Visible = True
  72.         btnExit.Visible = True
  73.         btnPrint.Visible = True
  74.  
  75.     End Sub
  76. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement