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 Label5 As System.Windows.Forms.Label Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents TextBox3 As System.Windows.Forms.TextBox Friend WithEvents TextBox4 As System.Windows.Forms.TextBox Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents Button4 As System.Windows.Forms.Button Friend WithEvents ListBox1 As System.Windows.Forms.ListBox Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.Label5 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.TextBox2 = New System.Windows.Forms.TextBox Me.TextBox3 = New System.Windows.Forms.TextBox Me.TextBox4 = New System.Windows.Forms.TextBox Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.RadioButton3 = New System.Windows.Forms.RadioButton Me.RadioButton2 = New System.Windows.Forms.RadioButton Me.RadioButton1 = New System.Windows.Forms.RadioButton Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.Button3 = New System.Windows.Forms.Button Me.Button4 = New System.Windows.Forms.Button Me.ListBox1 = New System.Windows.Forms.ListBox Me.GroupBox1.SuspendLayout() Me.SuspendLayout() ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 16.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(64, 16) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(288, 24) Me.Label1.TabIndex = 0 Me.Label1.Text = "The TEch Valley Car Dealer" ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(24, 56) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(184, 16) Me.Label2.TabIndex = 1 Me.Label2.Text = "Enter Purchase Price of Car" ' 'Label3 ' Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.Location = New System.Drawing.Point(24, 88) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(184, 16) Me.Label3.TabIndex = 2 Me.Label3.Text = "Enter Present Miles on Car" ' 'Label4 ' Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label4.Location = New System.Drawing.Point(24, 112) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(184, 16) Me.Label4.TabIndex = 3 Me.Label4.Text = "Enter Year Purchased" ' 'Label5 ' Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label5.Location = New System.Drawing.Point(24, 136) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(200, 24) Me.Label5.TabIndex = 4 Me.Label5.Text = "Estimated Years of Ownership" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(240, 56) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(160, 20) Me.TextBox1.TabIndex = 5 Me.TextBox1.Text = "" ' 'TextBox2 ' Me.TextBox2.Location = New System.Drawing.Point(240, 88) Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size(160, 20) Me.TextBox2.TabIndex = 6 Me.TextBox2.Text = "" ' 'TextBox3 ' Me.TextBox3.Location = New System.Drawing.Point(240, 112) Me.TextBox3.Name = "TextBox3" Me.TextBox3.Size = New System.Drawing.Size(160, 20) Me.TextBox3.TabIndex = 7 Me.TextBox3.Text = "" ' 'TextBox4 ' Me.TextBox4.Location = New System.Drawing.Point(240, 136) Me.TextBox4.Name = "TextBox4" Me.TextBox4.Size = New System.Drawing.Size(160, 20) Me.TextBox4.TabIndex = 8 Me.TextBox4.Text = "" ' 'GroupBox1 ' Me.GroupBox1.Controls.Add(Me.RadioButton3) Me.GroupBox1.Controls.Add(Me.RadioButton2) Me.GroupBox1.Controls.Add(Me.RadioButton1) Me.GroupBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.GroupBox1.Location = New System.Drawing.Point(16, 312) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(376, 56) Me.GroupBox1.TabIndex = 9 Me.GroupBox1.TabStop = False ' 'RadioButton3 ' Me.RadioButton3.Location = New System.Drawing.Point(256, 24) Me.RadioButton3.Name = "RadioButton3" Me.RadioButton3.TabIndex = 2 Me.RadioButton3.Text = "Poor" ' 'RadioButton2 ' Me.RadioButton2.Location = New System.Drawing.Point(136, 24) Me.RadioButton2.Name = "RadioButton2" Me.RadioButton2.TabIndex = 1 Me.RadioButton2.Text = "Fair" ' 'RadioButton1 ' Me.RadioButton1.Location = New System.Drawing.Point(16, 24) Me.RadioButton1.Name = "RadioButton1" Me.RadioButton1.TabIndex = 0 Me.RadioButton1.Text = "Good" ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(16, 376) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(80, 32) Me.Button1.TabIndex = 10 Me.Button1.Text = "New" ' 'Button2 ' Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(112, 376) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(72, 32) Me.Button2.TabIndex = 11 Me.Button2.Text = "Used" ' 'Button3 ' Me.Button3.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button3.Location = New System.Drawing.Point(208, 376) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(80, 32) Me.Button3.TabIndex = 12 Me.Button3.Text = "Clear" ' 'Button4 ' Me.Button4.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button4.Location = New System.Drawing.Point(312, 376) Me.Button4.Name = "Button4" Me.Button4.Size = New System.Drawing.Size(80, 32) Me.Button4.TabIndex = 13 Me.Button4.Text = "Close" ' 'ListBox1 ' Me.ListBox1.Items.AddRange(New Object() {"Purchase Year Selling Yearly " & _ " Total", "Condition Price Depreciation " & _ " Depreciation "}) Me.ListBox1.Location = New System.Drawing.Point(16, 168) Me.ListBox1.Name = "ListBox1" Me.ListBox1.Size = New System.Drawing.Size(376, 147) Me.ListBox1.TabIndex = 14 ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(408, 413) Me.Controls.Add(Me.ListBox1) Me.Controls.Add(Me.Button4) Me.Controls.Add(Me.Button3) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.GroupBox1) Me.Controls.Add(Me.TextBox4) Me.Controls.Add(Me.TextBox3) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" Me.GroupBox1.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click checker() 'call to checker to verify all entered values dim price as double dim miles as double dim year as double dim owned as double Dim dep_rate As Double price = CDbl(TextBox1.Text) miles = CDbl(TextBox2.Text) year = CDbl(TextBox3.Text) owned = CDbl(TextBox4.Text) dep_rate = 1 / 6 ListBox1.Items.add ("") compute(price, miles, year, owned, dep_rate) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click checker() 'call to checker to verify all entered values dim price as double dim miles as double dim year as double dim owned as double dim dep_rate as double price = CDbl(TextBox1.Text) miles = CDbl(TextBox2.Text) year = CDbl(TextBox3.Text) owned = CDbl(TextBox4.Text) dep_rate = 0.25 ListBox1.Items.add ("") compute(price, miles, year, owned, dep_rate) End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim settabs As String = "{0,-10}{1,-10}{2,-12}{3,-14}{4,-14}" TextBox1.Clear() TextBox2.Clear() TextBox3.Clear() TextBox4.Clear() With ListBox1.Items .Clear() .Add(String.Format(settabs, "Purchase", "Year", "Selling", "Yearly", "Total")) .Add(String.Format(settabs, "Condition", " ", "Price", "Depreciation", "Depreciation")) End With End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Me.Close() End Sub Private Sub checker() 'verify all datafields before commencing calculations Dim verify As Double Try verify = CDbl(TextBox1.Text) verify = CDbl(TextBox2.Text) verify = CDbl(TextBox3.Text) verify = CDbl(TextBox4.Text) Catch ex As Exception MessageBox.Show("Please Enter Proper Numerical Values", "Invalid Information") End Try If RadioButton1.Checked = False And RadioButton2.Checked = False And RadioButton3.Checked = False Then MessageBox.Show("Please Select Vehicle Condition", "Missing Information") Exit Sub End If End Sub Private Sub compute(ByVal price As Double, ByVal miles As Double, ByVal year As Double, ByVal owned As Double, ByVal dep_rate As Double) 'pass information to subroutine to handle calculations Dim value As Double Dim cond As String Dim value_loss As Double Dim i As Integer Dim settabs As String = "{0,-10}{1,-10}{2,-12}{3,-14}{4,-14}" Dim year_loss As Double Dim all_loss As Double Dim final_cost As Double Dim mile_loss As Double year_loss = (dep_rate * price) condition(cond, value_loss) For i = 0 To (owned - 1) Step 1 all_loss = all_loss + year_loss ListBox1.Items.Add(String.Format(settabs, cond, year, Format(price, "currency"), Format(year_loss, "currency"), Format(all_loss, "currency"))) year = year + 1 price = price - year_loss Next ListBox1.Items.Add("") 'miles calculate If miles > (owned * 12000) Then miles = miles - (owned * 12000) mile_loss = miles / 10 ListBox1.Items.Add(" Value lost from excess mileage: " & Format(mile_loss, "currency")) End If ListBox1.Items.Add("Value lost from vehicle condition: " & Format(value_loss, "currency")) final_cost = price - value_loss - mile_loss ListBox1.Items.Add("Present Trade-in Value: " & Format(final_cost, "currency")) End Sub Private Sub condition(ByRef cond As String, ByRef value_loss As Double) 'check radiobuttons and assign value If RadioButton1.Checked = True Then cond = "Good" value_loss = 0 Else If RadioButton2.Checked = True Then cond = "Fair" value_loss = 1000 Else If RadioButton3.Checked = True Then cond = "Poor" value_loss = 2000 End If End If End If End Sub End Class