Option Strict On Option Explicit On 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 Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents BtnExit As System.Windows.Forms.Button Friend WithEvents LblCommission As System.Windows.Forms.Label Friend WithEvents TxtSales As System.Windows.Forms.TextBox Friend WithEvents BtnCalculate As System.Windows.Forms.Button Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.LblCommission = New System.Windows.Forms.Label Me.TxtSales = New System.Windows.Forms.TextBox Me.BtnCalculate = New System.Windows.Forms.Button Me.BtnExit = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.ImageAlign = System.Drawing.ContentAlignment.BottomCenter Me.Label1.Location = New System.Drawing.Point(24, 24) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(120, 23) Me.Label1.TabIndex = 0 Me.Label1.Text = "Sales Amount -->" ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.ImageAlign = System.Drawing.ContentAlignment.BottomCenter Me.Label2.Location = New System.Drawing.Point(24, 64) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(120, 23) Me.Label2.TabIndex = 1 Me.Label2.Text = "Commission -->" ' 'LblCommission ' Me.LblCommission.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.LblCommission.Location = New System.Drawing.Point(136, 64) Me.LblCommission.Name = "LblCommission" Me.LblCommission.Size = New System.Drawing.Size(112, 23) Me.LblCommission.TabIndex = 2 ' 'TxtSales ' Me.TxtSales.Location = New System.Drawing.Point(136, 24) Me.TxtSales.MaxLength = 16 Me.TxtSales.Name = "TxtSales" Me.TxtSales.Size = New System.Drawing.Size(112, 20) Me.TxtSales.TabIndex = 3 Me.TxtSales.Text = "" ' 'BtnCalculate ' Me.BtnCalculate.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.BtnCalculate.Location = New System.Drawing.Point(264, 22) Me.BtnCalculate.Name = "BtnCalculate" Me.BtnCalculate.Size = New System.Drawing.Size(112, 24) Me.BtnCalculate.TabIndex = 4 Me.BtnCalculate.Text = "&Calculate Bonus" ' '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(264, 63) Me.BtnExit.Name = "BtnExit" Me.BtnExit.Size = New System.Drawing.Size(112, 24) Me.BtnExit.TabIndex = 5 Me.BtnExit.Text = "E&xit" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(392, 109) Me.Controls.Add(Me.BtnExit) Me.Controls.Add(Me.BtnCalculate) Me.Controls.Add(Me.TxtSales) Me.Controls.Add(Me.LblCommission) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = False Me.Name = "Form1" Me.Text = "Marshall Solution 1.0" Me.ResumeLayout(False) End Sub #End Region Private Sub TextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtSales.KeyPress Me.LblCommission.Text = "" If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back Then e.Handled = True End If If e.KeyChar = ControlChars.Cr Then BtnCalculate.PerformClick() End Sub Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click Me.Close() End Sub Private Sub CalcButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCalculate.Click Dim intSales As Long Dim dblCommission As Double = 0 If TxtSales.Text <> "" AndAlso TxtSales.Text.Chars(0) <> "0" Then 'To avoid an Empty input and "001" intSales = CLng(TxtSales.Text) Select Case intSales 'Select the proper case and Calculate the Commission Case 1 To 100000 dblCommission = intSales * 0.02 Case 100001 To 200000 dblCommission = 2000 + (intSales - 100000) * 0.04 Case 200001 To 300000 dblCommission = 6000 + (intSales - 200000) * 0.06 Case 300001 To 400000 dblCommission = 12000 + (intSales - 300000) * 0.08 Case Is >= 400001 dblCommission = 200000 + (intSales - 400000) * 0.1 End Select Me.LblCommission.Text = CStr(Format(dblCommission, "currency")) 'Display the Commission Else Me.LblCommission.Text = "" Me.TxtSales.Clear() End If Me.TxtSales.SelectAll() Me.TxtSales.Focus() End Sub End Class