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. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents Panel1 As System.Windows.Forms.Panel Friend WithEvents nudSalesPerUnit As System.Windows.Forms.NumericUpDown Friend WithEvents nudQuantity As System.Windows.Forms.NumericUpDown Friend WithEvents nudVarExpensesPerUnit As System.Windows.Forms.NumericUpDown Friend WithEvents txtSalesTotal As System.Windows.Forms.TextBox Friend WithEvents txtCM As System.Windows.Forms.TextBox Friend WithEvents txtCMPerUnit As System.Windows.Forms.TextBox Friend WithEvents nudFixedExpenses As System.Windows.Forms.NumericUpDown Friend WithEvents txtNetIncome As System.Windows.Forms.TextBox Friend WithEvents Panel2 As System.Windows.Forms.Panel Friend WithEvents Panel3 As System.Windows.Forms.Panel Friend WithEvents Panel4 As System.Windows.Forms.Panel Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents Label6 As System.Windows.Forms.Label Friend WithEvents Label7 As System.Windows.Forms.Label Friend WithEvents Label8 As System.Windows.Forms.Label Friend WithEvents txtVarExpenses As System.Windows.Forms.TextBox Friend WithEvents Label9 As System.Windows.Forms.Label Friend WithEvents txtCMRatio As System.Windows.Forms.TextBox Friend WithEvents btnCalculate As System.Windows.Forms.Button Private Sub InitializeComponent() Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1)) Me.Label1 = New System.Windows.Forms.Label Me.nudSalesPerUnit = New System.Windows.Forms.NumericUpDown Me.Label2 = New System.Windows.Forms.Label Me.nudQuantity = New System.Windows.Forms.NumericUpDown Me.nudVarExpensesPerUnit = New System.Windows.Forms.NumericUpDown Me.txtSalesTotal = New System.Windows.Forms.TextBox Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.Panel1 = New System.Windows.Forms.Panel Me.Panel2 = New System.Windows.Forms.Panel Me.txtCM = New System.Windows.Forms.TextBox Me.txtCMPerUnit = New System.Windows.Forms.TextBox Me.nudFixedExpenses = New System.Windows.Forms.NumericUpDown Me.txtNetIncome = New System.Windows.Forms.TextBox Me.Panel3 = New System.Windows.Forms.Panel Me.Panel4 = New System.Windows.Forms.Panel Me.Label5 = New System.Windows.Forms.Label Me.Label6 = New System.Windows.Forms.Label Me.Label7 = New System.Windows.Forms.Label Me.Label8 = New System.Windows.Forms.Label Me.txtVarExpenses = New System.Windows.Forms.TextBox Me.Label9 = New System.Windows.Forms.Label Me.txtCMRatio = New System.Windows.Forms.TextBox Me.btnCalculate = New System.Windows.Forms.Button CType(Me.nudSalesPerUnit, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.nudQuantity, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.nudVarExpensesPerUnit, System.ComponentModel.ISupportInitialize).BeginInit() Me.Panel1.SuspendLayout() CType(Me.nudFixedExpenses, System.ComponentModel.ISupportInitialize).BeginInit() Me.Panel3.SuspendLayout() Me.SuspendLayout() ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(8, 72) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(56, 16) Me.Label1.TabIndex = 0 Me.Label1.Text = "Sales" ' 'nudSalesPerUnit ' Me.nudSalesPerUnit.Location = New System.Drawing.Point(208, 72) Me.nudSalesPerUnit.Maximum = New Decimal(New Integer() {500, 0, 0, 0}) Me.nudSalesPerUnit.Name = "nudSalesPerUnit" Me.nudSalesPerUnit.Size = New System.Drawing.Size(80, 20) Me.nudSalesPerUnit.TabIndex = 1 Me.nudSalesPerUnit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right Me.nudSalesPerUnit.Value = New Decimal(New Integer() {10, 0, 0, 0}) ' 'Label2 ' Me.Label2.Location = New System.Drawing.Point(8, 104) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(104, 16) Me.Label2.TabIndex = 2 Me.Label2.Text = "Variable expenses:" ' 'nudQuantity ' Me.nudQuantity.Location = New System.Drawing.Point(176, 8) Me.nudQuantity.Maximum = New Decimal(New Integer() {1000000, 0, 0, 0}) Me.nudQuantity.Name = "nudQuantity" Me.nudQuantity.Size = New System.Drawing.Size(56, 20) Me.nudQuantity.TabIndex = 0 Me.nudQuantity.TextAlign = System.Windows.Forms.HorizontalAlignment.Right Me.nudQuantity.Value = New Decimal(New Integer() {10, 0, 0, 0}) ' 'nudVarExpensesPerUnit ' Me.nudVarExpensesPerUnit.Location = New System.Drawing.Point(208, 104) Me.nudVarExpensesPerUnit.Maximum = New Decimal(New Integer() {500, 0, 0, 0}) Me.nudVarExpensesPerUnit.Name = "nudVarExpensesPerUnit" Me.nudVarExpensesPerUnit.Size = New System.Drawing.Size(80, 20) Me.nudVarExpensesPerUnit.TabIndex = 2 Me.nudVarExpensesPerUnit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right Me.nudVarExpensesPerUnit.Value = New Decimal(New Integer() {5, 0, 0, 0}) ' 'txtSalesTotal ' Me.txtSalesTotal.Location = New System.Drawing.Point(120, 72) Me.txtSalesTotal.Name = "txtSalesTotal" Me.txtSalesTotal.ReadOnly = True Me.txtSalesTotal.Size = New System.Drawing.Size(64, 20) Me.txtSalesTotal.TabIndex = 5 Me.txtSalesTotal.Text = "0" Me.txtSalesTotal.TextAlign = System.Windows.Forms.HorizontalAlignment.Right ' 'Label3 ' Me.Label3.Location = New System.Drawing.Point(128, 48) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(56, 16) Me.Label3.TabIndex = 6 Me.Label3.Text = "Total" ' 'Label4 ' Me.Label4.Location = New System.Drawing.Point(216, 48) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(56, 16) Me.Label4.TabIndex = 7 Me.Label4.Text = "Per Unit" ' 'Panel1 ' Me.Panel1.BackColor = System.Drawing.SystemColors.ControlText Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.Panel1.Controls.Add(Me.Panel2) Me.Panel1.Location = New System.Drawing.Point(120, 136) Me.Panel1.Name = "Panel1" Me.Panel1.Size = New System.Drawing.Size(168, 2) Me.Panel1.TabIndex = 8 ' 'Panel2 ' Me.Panel2.BackColor = System.Drawing.SystemColors.ControlText Me.Panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.Panel2.Location = New System.Drawing.Point(-1, -1) Me.Panel2.Name = "Panel2" Me.Panel2.Size = New System.Drawing.Size(168, 2) Me.Panel2.TabIndex = 9 ' 'txtCM ' Me.txtCM.Location = New System.Drawing.Point(120, 144) Me.txtCM.Name = "txtCM" Me.txtCM.ReadOnly = True Me.txtCM.Size = New System.Drawing.Size(64, 20) Me.txtCM.TabIndex = 9 Me.txtCM.Text = "0" Me.txtCM.TextAlign = System.Windows.Forms.HorizontalAlignment.Right ' 'txtCMPerUnit ' Me.txtCMPerUnit.Location = New System.Drawing.Point(208, 144) Me.txtCMPerUnit.Name = "txtCMPerUnit" Me.txtCMPerUnit.ReadOnly = True Me.txtCMPerUnit.Size = New System.Drawing.Size(64, 20) Me.txtCMPerUnit.TabIndex = 10 Me.txtCMPerUnit.Text = "0" Me.txtCMPerUnit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right ' 'nudFixedExpenses ' Me.nudFixedExpenses.Location = New System.Drawing.Point(120, 176) Me.nudFixedExpenses.Maximum = New Decimal(New Integer() {1000000, 0, 0, 0}) Me.nudFixedExpenses.Name = "nudFixedExpenses" Me.nudFixedExpenses.Size = New System.Drawing.Size(80, 20) Me.nudFixedExpenses.TabIndex = 3 Me.nudFixedExpenses.TextAlign = System.Windows.Forms.HorizontalAlignment.Right Me.nudFixedExpenses.Value = New Decimal(New Integer() {1000, 0, 0, 0}) ' 'txtNetIncome ' Me.txtNetIncome.Location = New System.Drawing.Point(120, 216) Me.txtNetIncome.Name = "txtNetIncome" Me.txtNetIncome.ReadOnly = True Me.txtNetIncome.Size = New System.Drawing.Size(64, 20) Me.txtNetIncome.TabIndex = 12 Me.txtNetIncome.Text = "0" Me.txtNetIncome.TextAlign = System.Windows.Forms.HorizontalAlignment.Right ' 'Panel3 ' Me.Panel3.BackColor = System.Drawing.SystemColors.ControlText Me.Panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.Panel3.Controls.Add(Me.Panel4) Me.Panel3.Location = New System.Drawing.Point(120, 208) Me.Panel3.Name = "Panel3" Me.Panel3.Size = New System.Drawing.Size(80, 2) Me.Panel3.TabIndex = 13 ' 'Panel4 ' Me.Panel4.BackColor = System.Drawing.SystemColors.ControlText Me.Panel4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.Panel4.Location = New System.Drawing.Point(-1, -1) Me.Panel4.Name = "Panel4" Me.Panel4.Size = New System.Drawing.Size(168, 2) Me.Panel4.TabIndex = 9 ' 'Label5 ' Me.Label5.Location = New System.Drawing.Point(8, 144) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(112, 16) Me.Label5.TabIndex = 14 Me.Label5.Text = "Contribution margin:" ' 'Label6 ' Me.Label6.Location = New System.Drawing.Point(8, 176) Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(112, 16) Me.Label6.TabIndex = 15 Me.Label6.Text = "Less fixed expenses:" ' 'Label7 ' Me.Label7.Location = New System.Drawing.Point(8, 216) Me.Label7.Name = "Label7" Me.Label7.Size = New System.Drawing.Size(80, 16) Me.Label7.TabIndex = 16 Me.Label7.Text = "Net income:" ' 'Label8 ' Me.Label8.Location = New System.Drawing.Point(8, 8) Me.Label8.Name = "Label8" Me.Label8.Size = New System.Drawing.Size(168, 16) Me.Label8.TabIndex = 17 Me.Label8.Text = "Calculate for sales of (quantity):" ' 'txtVarExpenses ' Me.txtVarExpenses.Location = New System.Drawing.Point(120, 104) Me.txtVarExpenses.Name = "txtVarExpenses" Me.txtVarExpenses.ReadOnly = True Me.txtVarExpenses.Size = New System.Drawing.Size(64, 20) Me.txtVarExpenses.TabIndex = 18 Me.txtVarExpenses.Text = "0" Me.txtVarExpenses.TextAlign = System.Windows.Forms.HorizontalAlignment.Right ' 'Label9 ' Me.Label9.Location = New System.Drawing.Point(8, 256) Me.Label9.Name = "Label9" Me.Label9.Size = New System.Drawing.Size(184, 16) Me.Label9.TabIndex = 19 Me.Label9.Text = "Resulting contribution margin ratio:" ' 'txtCMRatio ' Me.txtCMRatio.Location = New System.Drawing.Point(192, 256) Me.txtCMRatio.Name = "txtCMRatio" Me.txtCMRatio.ReadOnly = True Me.txtCMRatio.Size = New System.Drawing.Size(64, 20) Me.txtCMRatio.TabIndex = 20 Me.txtCMRatio.Text = "0" Me.txtCMRatio.TextAlign = System.Windows.Forms.HorizontalAlignment.Right ' 'btnCalculate ' Me.btnCalculate.Location = New System.Drawing.Point(208, 208) Me.btnCalculate.Name = "btnCalculate" Me.btnCalculate.Size = New System.Drawing.Size(64, 32) Me.btnCalculate.TabIndex = 4 Me.btnCalculate.Text = "Calculate" ' 'Form1 ' Me.AcceptButton = Me.btnCalculate Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(328, 286) Me.Controls.Add(Me.btnCalculate) Me.Controls.Add(Me.txtCMRatio) Me.Controls.Add(Me.Label9) Me.Controls.Add(Me.txtVarExpenses) Me.Controls.Add(Me.Label8) Me.Controls.Add(Me.Label7) Me.Controls.Add(Me.Label6) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.Panel3) Me.Controls.Add(Me.txtNetIncome) Me.Controls.Add(Me.nudFixedExpenses) Me.Controls.Add(Me.txtCMPerUnit) Me.Controls.Add(Me.txtCM) Me.Controls.Add(Me.Panel1) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.txtSalesTotal) Me.Controls.Add(Me.nudVarExpensesPerUnit) Me.Controls.Add(Me.nudQuantity) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.nudSalesPerUnit) Me.Controls.Add(Me.Label1) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) Me.MaximizeBox = False Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Contribution Margin Ratio Calculation" CType(Me.nudSalesPerUnit, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.nudQuantity, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.nudVarExpensesPerUnit, System.ComponentModel.ISupportInitialize).EndInit() Me.Panel1.ResumeLayout(False) CType(Me.nudFixedExpenses, System.ComponentModel.ISupportInitialize).EndInit() Me.Panel3.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click Dim shrNetIncome As Short txtSalesTotal.Text = nudQuantity.Value * nudSalesPerUnit.Value txtVarExpenses.Text = nudQuantity.Value * nudVarExpensesPerUnit.Value txtCM.Text = txtSalesTotal.Text - txtVarExpenses.Text txtCMPerUnit.Text = nudSalesPerUnit.Value - nudVarExpensesPerUnit.Value shrNetIncome = Convert.ToInt16(txtCM.Text - nudFixedExpenses.Value) txtNetIncome.Text = Convert.ToString(shrNetIncome) txtCMRatio.Text = txtCM.Text / txtSalesTotal.Text End Sub End Class