Share via


SLN 函式

更新:2007 年 11 月

傳回 Double,指定單一期的資產直線折舊。

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

參數

  • Cost
    必要項。Double,指定資產的初始成本。

  • Salvage
    必要項。Double,指定資產在其報廢時的值。

  • Life
    必要項。Double,指定資產的使用年限。

例外狀況

例外狀況類型

錯誤代碼

條件

ArgumentException

5

Life = 0.

如果將使用非結構化錯誤處理的 Visual Basic 6.0 應用程式升級,請參閱「錯誤代碼」資料行 (您可以將錯誤代碼與 Number 屬性 (Err 物件) 比對)。但是,請盡可能考慮以 Visual Basic 的結構化例外處理概觀 取代這類錯誤控制項。

備註

折舊期間必須使用與 Life 引數相同的單位來表示。所有引數都必須為正數。

範例

這個範例會使用 SLN 函式來傳回單一期間的資產直線折舊,前提是提供資產的初始成本 (InitCost)、資產報廢時的變賣值 (SalvageVal) 和資產的總使用年限 (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

**模組︰**Financial

組件 (Assembly):Visual Basic Runtime Library (在 Microsoft.VisualBasic.dll 中)

請參閱

參考

SYD 函式

DDB 函式

財務摘要

ArgumentException