Option Explicit On Option Strict 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. Private Sub InitializeComponent() ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(200, 109) Me.Name = "Form1" Me.Opacity = 0.1 Me.Text = "Form1" End Sub #End Region Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim input As String Dim Another As Integer Dim sales, Commission As Double Do While (Another <> 7) ' If user click [No] --> exit loop Begin: input = InputBox("Enter the sales amount ") If input = "" Then GoTo WantEnd 'If Cancel --> Ask to Another If input.Chars(0) = " " OrElse input.ToLower <> input.ToUpper OrElse input.Length > 20 Then 'Avoid letters & Empty space Another and more than 20 digits MessageBox.Show("Invalid Value ", " Error...", MessageBoxButtons.OK, MessageBoxIcon.Error) GoTo Begin End If ' *** Calculations *** sales = Val(input) Select Case sales 'Select the proper case and Calculate the Commission Case 1 To 100000 Commission = sales * 0.02 Case 100001 To 200000 Commission = 2000 + (sales - 100000) * 0.04 Case 200001 To 300000 Commission = 6000 + (sales - 200000) * 0.06 Case 300001 To 400000 Commission = 12000 + (sales - 300000) * 0.08 Case Is >= 400001 Commission = 200000 + (sales - 400000) * 0.1 End Select 'Show Message with Commission result MessageBox.Show("For a Sales amount of --------> " & Format(sales, "currency") & ControlChars.Cr & ControlChars.Cr & ControlChars.Cr & "The Commission amount is ---> " & Format(Commission, "currency") & " " & ControlChars.Cr, "Marshall Solution 2.0", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) WantEnd: Another = CInt(MessageBox.Show(" Calculate another one ? ", "Marshall Solution 2.0", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) 'MessageBox.Show(" " & Another, "", MessageBoxButtons.OK, MessageBoxIcon.None) Loop Me.Close() End Sub End Class