Public Class Form1
Private amount As Double
Private total As Double
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim number As Integer
Double.TryParse(txtPriceItem.Text, amount)
Integer.TryParse(txtNumber.Text, number)
Dim subTotal As Double = number * amount
Dim VAT As Double = subTotal * 0.15
total = subTotal + VAT
txtVAT.Text = VAT.ToString("N2")
txtTotal.Text = total.ToString("N2")
btnCalculateChange.Enabled = True
End Sub
Private Sub btnCalculateChange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculateChange.Click
Double.TryParse(txtAmount.Text, amount)
Dim change As Double = amount - total
txtChange.Text = change.ToString("N2")
End Sub
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
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.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.txtChange = New System.Windows.Forms.TextBox()
Me.Label6 = New System.Windows.Forms.Label()
Me.txtTotal = New System.Windows.Forms.TextBox()
Me.Label5 = New System.Windows.Forms.Label()
Me.txtVAT = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.txtAmount = New System.Windows.Forms.TextBox()
Me.Label4 = New System.Windows.Forms.Label()
Me.txtNumber = New System.Windows.Forms.TextBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.btnCalculateChange = New System.Windows.Forms.Button()
Me.btnCalculate = New System.Windows.Forms.Button()
Me.Label3 = New System.Windows.Forms.Label()
Me.txtPriceItem = New System.Windows.Forms.TextBox()
Me.SuspendLayout()
'
'txtChange
'
Me.txtChange.Location = New System.Drawing.Point(147, 146)
Me.txtChange.Name = "txtChange"
Me.txtChange.ReadOnly = True
Me.txtChange.Size = New System.Drawing.Size(100, 20)
Me.txtChange.TabIndex = 12
'
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.Location = New System.Drawing.Point(86, 150)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(47, 13)
Me.Label6.TabIndex = 10
Me.Label6.Text = "Change:"
'
'txtTotal
'
Me.txtTotal.Location = New System.Drawing.Point(147, 94)
Me.txtTotal.Name = "txtTotal"
Me.txtTotal.ReadOnly = True
Me.txtTotal.Size = New System.Drawing.Size(100, 20)
Me.txtTotal.TabIndex = 15
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Location = New System.Drawing.Point(99, 98)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(34, 13)
Me.Label5.TabIndex = 11
Me.Label5.Text = "Total:"
'
'txtVAT
'
Me.txtVAT.Location = New System.Drawing.Point(147, 66)
Me.txtVAT.Name = "txtVAT"
Me.txtVAT.ReadOnly = True
Me.txtVAT.Size = New System.Drawing.Size(100, 20)
Me.txtVAT.TabIndex = 17
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(74, 70)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(60, 13)
Me.Label2.TabIndex = 8
Me.Label2.Text = "VAT (15%):"
'
'txtAmount
'
Me.txtAmount.Location = New System.Drawing.Point(147, 120)
Me.txtAmount.Name = "txtAmount"
Me.txtAmount.Size = New System.Drawing.Size(100, 20)
Me.txtAmount.TabIndex = 16
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Location = New System.Drawing.Point(60, 124)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(73, 13)
Me.Label4.TabIndex = 6
Me.Label4.Text = "Enter amount:"
'
'txtNumber
'
Me.txtNumber.Location = New System.Drawing.Point(147, 40)
Me.txtNumber.Name = "txtNumber"
Me.txtNumber.Size = New System.Drawing.Size(100, 20)
Me.txtNumber.TabIndex = 13
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(60, 44)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(73, 13)
Me.Label1.TabIndex = 7
Me.Label1.Text = "Enter number:"
'
'btnCalculateChange
'
Me.btnCalculateChange.Enabled = False
Me.btnCalculateChange.Location = New System.Drawing.Point(147, 180)
Me.btnCalculateChange.Name = "btnCalculateChange"
Me.btnCalculateChange.Size = New System.Drawing.Size(100, 23)
Me.btnCalculateChange.TabIndex = 4
Me.btnCalculateChange.Text = "Calculate change"
Me.btnCalculateChange.UseVisualStyleBackColor = True
'
'btnCalculate
'
Me.btnCalculate.Location = New System.Drawing.Point(55, 181)
Me.btnCalculate.Name = "btnCalculate"
Me.btnCalculate.Size = New System.Drawing.Size(75, 23)
Me.btnCalculate.TabIndex = 5
Me.btnCalculate.Text = "Calculate"
Me.btnCalculate.UseVisualStyleBackColor = True
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(10, 16)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(128, 13)
Me.Label3.TabIndex = 7
Me.Label3.Text = "Enter the price of an item:"
'
'txtPriceItem
'
Me.txtPriceItem.Location = New System.Drawing.Point(147, 13)
Me.txtPriceItem.Name = "txtPriceItem"
Me.txtPriceItem.Size = New System.Drawing.Size(100, 20)
Me.txtPriceItem.TabIndex = 13
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(277, 218)
Me.Controls.Add(Me.txtChange)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.txtTotal)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.txtVAT)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.txtAmount)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.txtPriceItem)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.txtNumber)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.btnCalculateChange)
Me.Controls.Add(Me.btnCalculate)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Calculator"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents txtChange As System.Windows.Forms.TextBox
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents txtTotal As System.Windows.Forms.TextBox
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents txtVAT As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents txtAmount As System.Windows.Forms.TextBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents txtNumber As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents btnCalculateChange As System.Windows.Forms.Button
Friend WithEvents btnCalculate As System.Windows.Forms.Button
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents txtPriceItem As System.Windows.Forms.TextBox
End Class
Comments
Leave a comment