This documentation is archived and is not being maintained.

# DDB Function

Visual Studio .NET 2003

Returns a Double specifying the depreciation of an asset for a specific time period using the double-declining balance method or some other method you specify.

Function DDB( _
ByVal Cost As Double, _
ByVal Salvage As Double, _
ByVal Life As Double, _
ByVal Period As Double, _
Optional ByVal Factor As Double = 2.0 _
) As Double

#### Parameters

Cost
Required. Double specifying initial cost of the asset.
Salvage
Required. Double specifying value of the asset at the end of its useful life.
Life
Required. Double specifying length of useful life of the asset.
Period
Required. Double specifying period for which asset depreciation is calculated.
Factor
Optional. Double specifying rate at which the balance declines. If omitted, 2 (double-declining method) is assumed.

#### Exceptions/Errors

Exception type Error number Condition
ArgumentException 5 Argument value < 0 or Period > Life.

#### Remarks

The double-declining balance method computes depreciation at an accelerated rate. Depreciation is highest in the first period and decreases in successive periods.

The Life and Period arguments must be expressed in the same units. For example, if Life is given in months, Period must also be given in months. All arguments must be positive numbers.

The DDB function uses the following formula to calculate depreciation for a given period:

Depreciation / Period = ((Cost – Salvage) * Factor) / Life

#### Example

This example uses the DDB function to return the depreciation of an asset for a specified period given the initial cost (InitCost), the salvage value at the end of the asset's useful life (SalvageVal), the total life of the asset in years (LifeTime), and the period in years for which the depreciation is calculated (Depr).

Sub testDDB()
Dim InitCost, SalvageVal, MonthLife, DepYear As Double
Dim Fmt As String
Const YRMOS As Integer = 12    ' Number of months in a year.
Fmt = "###,##0.00"
InitCost = CDbl(InputBox("What's the initial cost of the asset?"))
SalvageVal = CDbl(InputBox("Enter the asset's value at end of its life."))
MonthLife = CDbl(InputBox("What's the asset's useful life in months?"))
Do While MonthLife < YRMOS   ' Ensure period is >= 1 year.
MsgBox("Asset life must be a year or more.")
MonthLife = CDbl(InputBox("What's the asset's useful life in months?"))
Loop
LifeTime = MonthLife / YRMOS   ' Convert months to years.
If LifeTime <> Int(MonthLife / YRMOS) Then
End If
DepYear = CInt(InputBox("Enter year for depreciation calculation."))
Do While DepYear < 1 Or DepYear > LifeTime
MsgBox("You must enter at least 1 but not more than " & LifeTime)
DepYear = CDbl(InputBox("Enter year for depreciation calculation."))
Loop
Depr = DDB(InitCost, SalvageVal, LifeTime, DepYear)
MsgBox("The depreciation for year " & DepYear & " is " & _
Format(Depr, Fmt) & ".")
End Sub

#### Requirements

Namespace: Microsoft.VisualBasic

Module: Financial

Assembly: Microsoft Visual Basic .NET Runtime (in Microsoft.VisualBasic.dll)