' Tax Example ' Input a value, output the tax, which is 8% of amount. Public Class Form1 Inherits System.Windows.Forms.Form #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 txtAmount As System.Windows.Forms.TextBox Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents txtTax As System.Windows.Forms.TextBox Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents btnCompute As System.Windows.Forms.Button Private Sub InitializeComponent() Me.txtAmount = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.txtTax = New System.Windows.Forms.TextBox Me.Label2 = New System.Windows.Forms.Label Me.btnCompute = New System.Windows.Forms.Button Me.SuspendLayout() ' 'txtAmount ' Me.txtAmount.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtAmount.Location = New System.Drawing.Point(96, 24) Me.txtAmount.Name = "txtAmount" Me.txtAmount.Size = New System.Drawing.Size(232, 29) Me.txtAmount.TabIndex = 0 Me.txtAmount.Text = "" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(8, 24) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(80, 24) Me.Label1.TabIndex = 1 Me.Label1.Text = "Amount" ' 'txtTax ' Me.txtTax.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtTax.Location = New System.Drawing.Point(96, 64) Me.txtTax.Name = "txtTax" Me.txtTax.Size = New System.Drawing.Size(232, 29) Me.txtTax.TabIndex = 2 Me.txtTax.Text = "" ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(48, 64) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(48, 24) Me.Label2.TabIndex = 3 Me.Label2.Text = "Tax" ' 'btnCompute ' Me.btnCompute.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.btnCompute.Location = New System.Drawing.Point(96, 104) Me.btnCompute.Name = "btnCompute" Me.btnCompute.Size = New System.Drawing.Size(232, 40) Me.btnCompute.TabIndex = 4 Me.btnCompute.Text = "Compute Tax" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(352, 166) Me.Controls.Add(Me.btnCompute) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.txtTax) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.txtAmount) Me.Name = "Form1" Me.Text = "Tax Example" Me.ResumeLayout(False) End Sub #End Region Private Sub btnCompute_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnCompute.Click Dim amount, tax As Double amount = txtAmount.Text tax = 0.08 * amount txtTax.Text = tax.ToString("$#,##0.00") End Sub End Class