SLN Function

Returns a Double specifying the straight-line depreciation of an asset for a single period.

Function SLN( _
   ByVal Cost As Double, _
   ByVal Salvage As Double, _
   ByVal Life As Double _
) As Double

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.

Exception type

Error number

Condition

ArgumentException

5

Life = 0.

See the "Error number" column if you are upgrading Visual Basic 6.0 applications that use unstructured error handling. (You can compare the error number against the Number Property (Err Object).) However, when possible, you should consider replacing such error control with Structured Exception Handling Overview for Visual Basic.

The depreciation period must be expressed in the same unit as the Life argument. All arguments must be positive numbers.

This example uses the SLN function to return the straight-line depreciation of an asset for a single 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).

Dim InitCost, SalvageVal, LifeTime, DepYear As Double 
Dim Fmt As String = "###,##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."))
LifeTime = CDbl(InputBox("What's the asset's useful life in years?"))

' Use the SLN function to calculate the deprecation per year. 
Dim SlnDepr As Double = SLN(InitCost, SalvageVal, LifeTime)
Dim msg As String = "The depreciation per year: " & Format(SlnDepr, Fmt)
msg &= vbCrLf & "Year" & vbTab & "Linear" & vbTab & "Doubling" & vbCrLf

' Use the SYD and DDB functions to calculate the deprecation for each year. 
For DepYear = 1 To LifeTime
    msg &= DepYear & vbTab & _
        Format(SYD(InitCost, SalvageVal, LifeTime, DepYear), Fmt) & vbTab & _
        Format(DDB(InitCost, SalvageVal, LifeTime, DepYear), Fmt) & vbCrLf
Next
MsgBox(msg)

Namespace: Microsoft.VisualBasic

Module: Financial

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

Community Additions

ADD
Show: