Public Class frmSalesTax
  Inherits System.Windows.Forms.Form
  Const SalesTaxRate As Double = 0.05

#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

  End Sub

  'Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
      If Not (components Is Nothing) Then
        components.Dispose()
      End If
    End If
    MyBase.Dispose(disposing)
  End Sub

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.IContainer

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  Friend WithEvents Label1 As System.Windows.Forms.Label
  Friend WithEvents Label2 As System.Windows.Forms.Label
  Friend WithEvents btnExit As System.Windows.Forms.Button
  Friend WithEvents txtCost As System.Windows.Forms.TextBox
  Friend WithEvents txtTax As System.Windows.Forms.TextBox
  Friend WithEvents btnCalc As System.Windows.Forms.Button
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.Label1 = New System.Windows.Forms.Label()
    Me.Label2 = New System.Windows.Forms.Label()
    Me.txtCost = New System.Windows.Forms.TextBox()
    Me.txtTax = New System.Windows.Forms.TextBox()
    Me.btnCalc = New System.Windows.Forms.Button()
    Me.btnExit = New System.Windows.Forms.Button()
    Me.SuspendLayout()
    '
    'Label1
    '
    Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
    Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Label1.Location = New System.Drawing.Point(8, 8)
    Me.Label1.Name = "Label1"
    Me.Label1.Size = New System.Drawing.Size(96, 20)
    Me.Label1.TabIndex = 0
    Me.Label1.Text = "Item Cost:"
    Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
    '
    'Label2
    '
    Me.Label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
    Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Label2.Location = New System.Drawing.Point(8, 32)
    Me.Label2.Name = "Label2"
    Me.Label2.Size = New System.Drawing.Size(96, 20)
    Me.Label2.TabIndex = 1
    Me.Label2.Text = "Sales tax due"
    Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
    '
    'txtCost
    '
    Me.txtCost.Location = New System.Drawing.Point(104, 8)
    Me.txtCost.Name = "txtCost"
    Me.txtCost.Size = New System.Drawing.Size(112, 20)
    Me.txtCost.TabIndex = 2
    Me.txtCost.Text = ""
    '
    'txtTax
    '
    Me.txtTax.Location = New System.Drawing.Point(104, 32)
    Me.txtTax.Name = "txtTax"
    Me.txtTax.Size = New System.Drawing.Size(112, 20)
    Me.txtTax.TabIndex = 3
    Me.txtTax.Text = ""
    '
    'btnCalc
    '
    Me.btnCalc.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.btnCalc.Location = New System.Drawing.Point(8, 88)
    Me.btnCalc.Name = "btnCalc"
    Me.btnCalc.Size = New System.Drawing.Size(96, 23)
    Me.btnCalc.TabIndex = 4
    Me.btnCalc.Text = "&Calculate"
    '
    'btnExit
    '
    Me.btnExit.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.btnExit.Location = New System.Drawing.Point(120, 88)
    Me.btnExit.Name = "btnExit"
    Me.btnExit.Size = New System.Drawing.Size(96, 23)
    Me.btnExit.TabIndex = 5
    Me.btnExit.Text = "E&xit"
    '
    'frmSalesTax
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(224, 141)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnExit, Me.btnCalc, Me.txtTax, Me.txtCost, Me.Label2, Me.Label1})
    Me.Name = "frmSalesTax"
    Me.Text = "Calculate Sales Tax Due"
    Me.ResumeLayout(False)

  End Sub

#End Region

  Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
    Me.Dispose()
  End Sub


  Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
    Dim ItemPrice As Double, SalesTaxDue As Double

    ItemPrice = CDbl(txtCost.Text)
    SalesTaxDue = CalcSalesTax(ItemPrice)
    txtTax.Text = CStr(SalesTaxDue)

  End Sub

  Private Function CalcSalesTax(ByVal Price As Double) As Double
    '  Private Sub CalcSalesTax(ByVal Price As Double, ByVal SalesTax As Double)
    ' Purpose: This subroutine calculates the sales tax
    '          that is to be collected for a given item.
    '
    ' Arguments:
    '   Price     the purchase price of the item
    '   SalesTax  the sales tax amount to collect
    '
    ' Return Value:
    '   double    the sales tax due for this sale
    '
    ' Caution: the calculation uses the symbolic constant
    '          SalesTaxRate, which holds the current sales
    '          tax rate.

    CalcSalesTax = Price * SalesTaxRate
  End Function

End Class
