# Financial Calculation Using .NET: Depreciation: Part 2

By , 16 Jul 2013
Votes of 3 or less require a comment

## Introduction

In this article we will look at how we can use the `Microsoft.VisualBasic` namespace to do single line and double line depreciation calculation.

I have been writing and recording a lot of architecture related videos on Design Patterns, UML, FPA estimation, Enterprise Application Blocks, C# projects, etc., you can watch my videos at http://www.questpond.com.

## Other Articles of Financial Calculation

• Future value calculation: FinanceCalculation.aspx

## Definition of Depreciation

Any asset we buy for an organization has a finite life time. As time passes by the asset loses value. Depreciation helps us to evaluate the wear and tear for fixed assets over a period of time.

## Understanding Single Line Depreciation

Straight line depreciation is the simplest and widely used technique. The below figure ‘straight line depreciation’ shows the complete formula. A fixed cost asset is the total cost of the asset. The scrap value is the asset value when it will be finally sold or disposed. For instance, let’s say you bought a computer and you use it for 5 years. Even after five years the computer will still sell for some amount. There is a possibility depending on the asset that the scrap value can be zero. The life span of the asset is the total life time of the asset.

To calculate straight line depreciation we need to use the SLN formulae. It takes three values: the fixed cost which is termed as cost in Excel, scrap value also called as salvage value, and the life of the asset. This returns us the depreciation calculation per month.

So for an asset of fixed cost 15000, scrap value of 2000, and life span of 5 years, below is the spread and calculation:

 Years First year Second year Third year Fourth year Fifth year Depreciation Value 2600 2600 2600 2600 2600 Total Depreciation 13000 Balance 2000

## Understanding Double Declining Depreciation

Double declining is a type of acceleration depreciation method. Accelerated depreciation means it recognizes a higher depreciation at the beginning of the life time of the asset. First let’s understand what declining appreciation is. Double declining depreciation value is twice the value of straight line depreciation. In double declining, previous year's asset value becomes the input to the next year’s depreciation calculation. The below figure ‘Double declining balance’ shows how calculations are done for every year. The basic formula for calculating depreciation is as below.

Depreciation expense = previous period value * ( Factor / Life of Asset )

From the above formula we will get depreciation expense on a per month basis. The previous period value is the value of the asset after deducting the depreciation of that year. Factor value is two for double declining depreciation.

So let’s analyze the below calculation for double declining balance. In the below example we have an asset of cost around 19000 with a scrap value of 2000 and the life of the asset is five years. So the first year of calculation is fixed cost multiplied by factor divided by life of asset, which comes to around 7600. Now to calculate for the second year, we subtract the depreciation of the first year from the fixed cost and multiply by a factor divided by the life of the asset. In the same way we carry forward for third and fourth years. Now for the fifth year we deduct the previous brought forward from the scrap value, because this is the final year of the life of the asset. So for the final year, the depreciation is 462. Try to follow the way carry forwards are taken from the previous year to the next year, this will clear your fundamentals in a more appropriate manner.

## The Source Code

Now let's see how we can achieve the above two things using the `Financial` class provided in the `Microsoft.VisualBasic` namespace.

First let's create a class which has the year and the value of the depreciation, below is the code for that:

```public class clsYearValue
{
private int _intYear;
private double _dblCalculated;
public int Year
{
set
{
_intYear = value;
}
get
{
return _intYear;
}
}
public double CalculatedAmount
{
set
{
_dblCalculated = value;
}
get
{
return _dblCalculated;
}
}
}```

Definitely when we talk about depreciation it will have a collection of values with year. So let’s create a strongly typed class called `clsYearValues` which holds a collection of the `clsYearValue` class.

```public class clsYearValue
public class clsYearValues : CollectionBase
{
{
}
}```

We will create a function which will take in the number of years, salvage value, and fixed cost. So first let’s create an object of year class and year’s class which is a collection.

```clsYearValues objYearValues = new clsYearValues();
clsYearValue objYear = new clsYearValue();```

Depending on the number of years, we will loop and get the single line depreciation value using the SLN function of the static `Financial` class. Once the value is calculated we add the object to the collection.

```for (int itemp = 1; itemp <= NumberOfYears; itemp++)
{
objYear = new clsYearValue();
objYear.Year = itemp;
objYear.CalculatedAmount = Financial.SLN(FixedCost, ScrapValue, NumberOfYears);
}```

To calculate double declining, we again loop and use the `DBB` function of the `Financial` static class. Once we get the value, we add the value to the collection.

```for (int itemp = 1; itemp <= NumberOfYears; itemp++)
{
objYear = new clsYearValue();
objYear.Year = itemp;
objYear.CalculatedAmount = Financial.DDB(FixedCost, ScrapValue, NumberOfYears, itemp, 2);
}```

The function also takes which type of calculation to perform. If we pass 1 in the function it will calculate single line depreciation and for 2, it will calculate double line depreciation.

Finally we create the object of the `Financial` class and calculate single line and double line depreciation. We first pass 1 to calculate single line depreciation and 2 for double line. We have created two `DataGrid`s: one which binds the single line depreciation calculation and one for double line depreciation calculations.

```protected void btnCalculate_Click(object sender, EventArgs e)
{
clsFinancial objFinancial = new clsFinancial();
DataGrid1.DataSource = objFinancial.Calculate(Convert.ToDouble(txtValueofAsset.Text),
Convert.ToDouble(txtScrapValue.Text),
Convert.ToInt16(txtLifeofAsset.Text), 1);
DataGrid1.DataBind();
DataGrid2.DataSource = objFinancial.Calculate(Convert.ToDouble(txtValueofAsset.Text),
Convert.ToDouble(txtScrapValue.Text),
Convert.ToInt16(txtLifeofAsset.Text), 2);
DataGrid2.DataBind();
}```

Below is the screenshot which shows single line and double line depreciation for 20 years with a scrap value of 1000 and asset value of 50000. To download the source code, click here.

Architect http://www.questpond.com
India

I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small
E-learning company in India. We are very much active in making training videos ,
writing books and corporate trainings. Do visit my site for
.NET, C# , design pattern , WCF , Silverlight
, LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server  training

 First Prev Next
 3d party component Member 6698002 16-Jul-13 23:08
 Nice! +5 Member 455866 16-Jul-13 10:36
 Good one SrikantgklNbo 31-Oct-08 0:22
 Re: Good one Shivprasad koirala 31-Oct-08 0:29
 Last Visit: 31-Dec-99 18:00     Last Update: 9-Dec-13 20:17 Refresh 1