Answer to Question #189181 in Visual Basic for Don

Question #189181

The Financial officer at RGI wants you to develop an application that will evaluate the company’s asset’s annual depreciation using the double-declining balance and sum-of-the years’ digit method. The interface provides text boxes for entering the asset cost and salvage value. It also provides a list box for selecting the useful life, which ranges from 3 to 20 years. The depreciation amounts are displayed in the list boxes.


1
Expert's answer
2021-05-05T23:59:31-0400
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmMain
    Inherits System.Windows.Forms.Form


    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    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.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.txtAssetCost = New System.Windows.Forms.TextBox()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.txtSalvageValue = New System.Windows.Forms.TextBox()
        Me.lstUsefulLife = New System.Windows.Forms.ListBox()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.btnDisplayDepreciationSchedules = New System.Windows.Forms.Button()
        Me.btnExit = New System.Windows.Forms.Button()
        Me.GroupBox1 = New System.Windows.Forms.GroupBox()
        Me.lstSumYearDigit = New System.Windows.Forms.ListBox()
        Me.Label5 = New System.Windows.Forms.Label()
        Me.lstDoubleDecliningBalance = New System.Windows.Forms.ListBox()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(39, 35)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(59, 13)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Asset cost:"
        '
        'txtAssetCost
        '
        Me.txtAssetCost.Location = New System.Drawing.Point(127, 32)
        Me.txtAssetCost.Name = "txtAssetCost"
        Me.txtAssetCost.Size = New System.Drawing.Size(100, 20)
        Me.txtAssetCost.TabIndex = 0
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(39, 104)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(78, 13)
        Me.Label2.TabIndex = 0
        Me.Label2.Text = "Salvage value:"
        '
        'txtSalvageValue
        '
        Me.txtSalvageValue.Location = New System.Drawing.Point(127, 101)
        Me.txtSalvageValue.Name = "txtSalvageValue"
        Me.txtSalvageValue.Size = New System.Drawing.Size(100, 20)
        Me.txtSalvageValue.TabIndex = 1
        '
        'lstUsefulLife
        '
        Me.lstUsefulLife.FormattingEnabled = True
        Me.lstUsefulLife.Location = New System.Drawing.Point(127, 164)
        Me.lstUsefulLife.Name = "lstUsefulLife"
        Me.lstUsefulLife.Size = New System.Drawing.Size(100, 95)
        Me.lstUsefulLife.TabIndex = 2
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.Location = New System.Drawing.Point(39, 164)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(56, 13)
        Me.Label3.TabIndex = 0
        Me.Label3.Text = "Useful life:"
        '
        'btnDisplayDepreciationSchedules
        '
        Me.btnDisplayDepreciationSchedules.Location = New System.Drawing.Point(20, 286)
        Me.btnDisplayDepreciationSchedules.Name = "btnDisplayDepreciationSchedules"
        Me.btnDisplayDepreciationSchedules.Size = New System.Drawing.Size(207, 49)
        Me.btnDisplayDepreciationSchedules.TabIndex = 3
        Me.btnDisplayDepreciationSchedules.Text = "Display Depreciation Schedules"
        Me.btnDisplayDepreciationSchedules.UseVisualStyleBackColor = True
        '
        'btnExit
        '
        Me.btnExit.Location = New System.Drawing.Point(520, 286)
        Me.btnExit.Name = "btnExit"
        Me.btnExit.Size = New System.Drawing.Size(138, 49)
        Me.btnExit.TabIndex = 4
        Me.btnExit.Text = "Exit"
        Me.btnExit.UseVisualStyleBackColor = True
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.lstSumYearDigit)
        Me.GroupBox1.Controls.Add(Me.Label5)
        Me.GroupBox1.Controls.Add(Me.lstDoubleDecliningBalance)
        Me.GroupBox1.Controls.Add(Me.Label4)
        Me.GroupBox1.Location = New System.Drawing.Point(249, 32)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(435, 227)
        Me.GroupBox1.TabIndex = 4
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "Depreciation schedules"
        '
        'lstSumYearDigit
        '
        Me.lstSumYearDigit.FormattingEnabled = True
        Me.lstSumYearDigit.Location = New System.Drawing.Point(222, 41)
        Me.lstSumYearDigit.Name = "lstSumYearDigit"
        Me.lstSumYearDigit.Size = New System.Drawing.Size(187, 173)
        Me.lstSumYearDigit.TabIndex = 1
        '
        'Label5
        '
        Me.Label5.AutoSize = True
        Me.Label5.Location = New System.Drawing.Point(219, 24)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(113, 13)
        Me.Label5.TabIndex = 0
        Me.Label5.Text = "Sum-of-the years' digit:"
        '
        'lstDoubleDecliningBalance
        '
        Me.lstDoubleDecliningBalance.FormattingEnabled = True
        Me.lstDoubleDecliningBalance.Location = New System.Drawing.Point(22, 41)
        Me.lstDoubleDecliningBalance.Name = "lstDoubleDecliningBalance"
        Me.lstDoubleDecliningBalance.Size = New System.Drawing.Size(187, 173)
        Me.lstDoubleDecliningBalance.TabIndex = 0
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.Location = New System.Drawing.Point(19, 24)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(130, 13)
        Me.Label4.TabIndex = 0
        Me.Label4.Text = "Double-declining balance:"
        '
        'frmMain
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(699, 363)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.btnExit)
        Me.Controls.Add(Me.btnDisplayDepreciationSchedules)
        Me.Controls.Add(Me.lstUsefulLife)
        Me.Controls.Add(Me.txtSalvageValue)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.txtAssetCost)
        Me.Controls.Add(Me.Label1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmMain"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "RGI Asset Annual Depreciation App"
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox1.PerformLayout()
        Me.ResumeLayout(False)
        Me.PerformLayout()


    End Sub
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents txtAssetCost As System.Windows.Forms.TextBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents txtSalvageValue As System.Windows.Forms.TextBox
    Friend WithEvents lstUsefulLife As System.Windows.Forms.ListBox
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents btnDisplayDepreciationSchedules As System.Windows.Forms.Button
    Friend WithEvents btnExit As System.Windows.Forms.Button
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents lstSumYearDigit As System.Windows.Forms.ListBox
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents lstDoubleDecliningBalance As System.Windows.Forms.ListBox
    Friend WithEvents Label4 As System.Windows.Forms.Label


End Class





Public Class frmMain


    ''' <summary>
    ''' Main form load
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For y As Integer = 3 To 20
            lstUsefulLife.Items.Add(y.ToString())
        Next
        lstUsefulLife.SelectedIndex = 0
    End Sub


    ''' <summary>
    ''' Display Depreciation Schedules button
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub btnDisplayDepreciationSchedules_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayDepreciationSchedules.Click
        Dim assetCost As Decimal
        Dim salvageValue As Decimal
        Dim usefulLife As Integer
        If Decimal.TryParse(txtAssetCost.Text, assetCost) = False Then
            MsgBox("Enter the asset cost.")
            txtAssetCost.Clear()
            txtAssetCost.Focus()
            Return
        End If
        If Decimal.TryParse(txtSalvageValue.Text, salvageValue) = False Then
            MsgBox("Enter the salvage value.")
            txtSalvageValue.Clear()
            txtSalvageValue.Focus()
            Return
        End If


        If Integer.TryParse(lstUsefulLife.SelectedItem.ToString(), usefulLife) = False Then
            MsgBox("Enter the useful life.")
            lstUsefulLife.Focus()
            Return
        End If
        lstDoubleDecliningBalance.Items.Clear()
        lstSumYearDigit.Items.Clear()
        lstDoubleDecliningBalance.Items.Add("Year" + vbTab + vbTab + "Depreciation")
        lstSumYearDigit.Items.Add("Year" + vbTab + vbTab + "Depreciation")
        For y As Integer = 1 To usefulLife
            Dim depreciation As Decimal = Financial.DDB(assetCost, salvageValue, usefulLife, y)
            lstDoubleDecliningBalance.Items.Add(y.ToString() + vbTab + vbTab + depreciation.ToString("N"))
            depreciation = Financial.SYD(assetCost, salvageValue, usefulLife, y)
            lstSumYearDigit.Items.Add(y.ToString() + vbTab + vbTab + depreciation.ToString("N"))
        Next


    End Sub


    ''' <summary>
    ''' Exit button
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub


 
End Class




Output:



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS