In visual studio express 2012 I need to write a program in V
In visual studio express 2012
I need to write a program in Visual Basic
Depreciation to a Salvage Value of 0. For tax purposes an item may be depreciated over a period of several years, n. With the straight-line method of depreciation, each year the item depreciates by 1/nth of its original value. With the double-declining-balance method of depreciation, each year the item depreciates by 2/nths of its value at the beginning of that year. (In the last year, it is depreciated by its value at the beginning of the year.) Write a program that performs the following tasks:
(a) Requests a description of the item, the year of purchase, the cost of the item, the number of years to be depreciated (estimated life), and the method of depreciation. The method of depreciation should be chosen by clicking one of two buttons.
(b) Display a year-by-year depreciation schedule for the item similar to the schedule shown below.
Solution
Solution:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim yearpurchased, cost, life, depreciation, begvalue, total As Double
Dim item As String
Dim fmt As String = \"{0,-7}{1,10}{2,16}{3,20}\"
Dim numberyears As Integer
item = txtItem.Text
yearpurchased = txtYear.Text
cost = txtCost.Text
life = txtLife.Text
listDepreciation.Items.Clear()
listDepreciation.Items.Add(\"Descriptio… \" & item)
listDepreciation.Items.Add(\"Year of purchase: \" & yearpurchased)
listDepreciation.Items.Add(\"Cost: \" & FormatCurrency(cost))
listDepreciation.Items.Add(\"Estimated life: \" & life)
listDepreciation.Items.Add(\"Method of depreciation: straight-line\")
listDepreciation.Items.Add(\" \")
listDepreciation.Items.Add(String.Format(fmt, \"\", \"Value at\", \"Amount Deprec\", \"Total Depreciation\"))
listDepreciation.Items.Add(String.Format(fmt, \"Year\", \"Beg of Yr\", \"During Year\", \"to End of Year\"))
depreciation = (2 * cost) / life
begvalue = cost
For numberyears = 1 To life
total += depreciation
listDepreciation.Items.Add(String.Format(fmt, _
yearpurchased, _
FormatNumber(begvalue), _
FormatNumber(depreciation), _
FormatNumber(total)))
begvalue = begvalue - depreciation \'This is the code I need to stop when For reaches life.
depreciation = (begvalue * 2) / life
yearpurchased = yearpurchased + 1
Next
End Sub
End Class
