You are on page 1of 5

STRAIGHT LINE DEPRECIATION CALCULATOR

The code below is used for calculation of depreciation of different items using the straight
line depreciation method.
Private Sub cmdSch_Click()
'Declaration of variables
Dim itm As String, cst, salv, yr, lf As Integer
Dim depr_pa As Double, i As Integer
'Input and display the Year of purchase
yr = InputBox("Enter Year of purchase")
ListBox4.AddItem (yr)
'Input and display theItem Description
itm = InputBox("Enter Item description")
ListBox1.AddItem (itm)
'Input and display theCost of the item
cst = InputBox("Enter Cost of item")
ListBox2.AddItem (cst)
'Input and display the Salvage value
salv = InputBox("Enter Salvage value")
ListBox3.AddItem (salv)
'Input and display the Estimated life of the item
lf = InputBox("Enter the Estimated life of the item")
ListBox5.AddItem (lf)
'Output
lstOutput.AddItem ("Item Description: " & itm)
lstOutput.AddItem ("Year of purchase: " & yr)
lstOutput.AddItem ("Item Cost: $" & cst)
lstOutput.AddItem ("Salvage Value: $" & salv)
lstOutput.AddItem ("Estimated Life: " & lf)
lstOutput.AddItem ("")
Do While i < lf
'Do while loop to calculate depreciation for
' every yaer in the item's estimated life
Dim year As Integer
Dim acc_dep As Integer
Dim bk_val As Integer
'Calculate Straight line depreciation
depr_pa = (cst - salv) / lf
year = year + 1
acc_dep = depr_pa * year
'Output book value at the beginning of first year
'as equal tot the cost of item
If (year = 1) Then
bk_val = cst
yr = yr

Else
bk_val = cst - acc_dep
yr = yr + 1
End If 'End of If Statement
i=i+1
'Exits operation out of the Do While loop
'when Book Value is less than the Salvage value
If (bk_val < salv) Then
Exit Do
End If 'End of If Statement
'Output
lstOutput.AddItem ("Book Value at the beginning of " & yr & " is $" & bk_val)
lstOutput.AddItem ("Depreciation of year: " & year & ": " & yr & " is " & depr_pa)
lstOutput.AddItem ("Accumulated Depreciation: $" & acc_dep)
lstOutput.AddItem ("")
Loop 'End of do while loop
lstOutput.AddItem ("Book Value at the end of " & yr & " is down to $" & bk_val)
lstOutput.AddItem ("Book Value is $" & cst & " minus $" & acc_dep)
lstOutput.AddItem ("This equals the salvage value of &" & salv)
End Sub
Private Sub cmdExit_Click()
'Exits the program
Unload Me
End Sub
Private Sub cmdClr_Click()
'Clears the list boxes of all contents
lstOutput.Clear
ListBox1.Clear
ListBox2.Clear
ListBox3.Clear
ListBox4.Clear
ListBox5.Clear
End Sub

Output
The working of the depreciation calculator is as depicted below in the screen captures
Depreciation Calculator

Inputting required values

Year of purchase

Item Description

Cost of the item

Salvage Value

Estimated life

Straight line depreciation

Output

You might also like