# SYD Function

Visual Studio .NET 2003

Returns a Double specifying the sum-of-years digits depreciation of an asset for a specified period.

```Function SYD( _
ByVal Cost As Double, _
ByVal Salvage As Double, _
ByVal Life As Double, _
ByVal Period As Double _
) 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 the useful life of the asset.
Period
Required. Double specifying period for which asset depreciation is calculated.

#### Exceptions/Errors

Exception type Error number Condition
ArgumentException 5 Salvage < 0, Period > Life, or Period <=0.

#### Remarks

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.

#### Example

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

```Sub TestSYD()
Dim InitCost, SalvageVal, MonthLife, DepYear, LifeTime, Pdepr As Double
Dim Fmt As String = "###,##0.00"   ' Define money format.
Const YEARMONTHS As Integer = 12  ' Number of months in a year.
InitCost = CDbl(InputBox("What's the initial cost of the asset?"))
SalvageVal = CDbl(InputBox("What's the asset's value at the end of its life?"))
MonthLife = CDbl(InputBox("What's the asset's useful life in months?"))
Do While MonthLife < YEARMONTHS   ' 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 / YEARMONTHS   ' Convert months to years.
If LifeTime <> Int(MonthLife / YEARMONTHS) Then
End If
DepYear = CInt(InputBox("For which year do you want depreciation?"))
Do While DepYear < 1 Or DepYear > LifeTime
MsgBox("You must enter at least 1 but not more than " & LifeTime)
DepYear = CInt(InputBox("For what year do you want depreciation?"))
Loop
Pdepr = SYD(InitCost, SalvageVal, LifeTime, DepYear)
MsgBox("The depreciation for year " & DepYear & " is " & Format(Pdepr, Fmt) & ".")
End Sub
```

#### Requirements

Namespace: Microsoft.VisualBasic

Module: Financial

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