# DDB 函数DDB function

## 语法Syntax

DDB(成本抢救生命周期、[因子])DDB(cost, salvage, life, period, [ factor ])

DDB 函数具有以下命名参数The DDB function has these named arguments:

PartPart 说明Description

## 说明Remarks

lifeperiod 参数必须用相同的单位表示。The life and period arguments must be expressed in the same units. 例如，如果以月份表示 life，则也必须以月份表示 periodFor example, if life is given in months, period must also be given in months. 所有参数都必须是正数。All arguments must be positive numbers.

DDB 函数使用以下公式计算给定期间的折旧额：The DDB function uses the following formula to calculate depreciation for a given period:

## 示例Example

``````Dim Fmt, InitCost, SalvageVal, MonthLife, LifeTime, DepYear, Depr
Const YRMOS = 12    ' Number of months in a year.
Fmt = "###,##0.00"
InitCost = InputBox("What's the initial cost of the asset?")
SalvageVal = InputBox("Enter the asset's value at end of its life.")
MonthLife = 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 = InputBox("What's the asset's useful life in months?")
Loop
LifeTime = MonthLife / YRMOS    ' Convert months to years.
If LifeTime <> Int(MonthLife / YRMOS) Then
LifeTime = Int(LifeTime + 1)    ' Round up to nearest year.
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 = InputBox("Enter year for depreciation calculation.")
Loop
Depr = DDB(InitCost, SalvageVal, LifeTime, DepYear)
MsgBox "The depreciation for year " & DepYear & " is " & _
Format(Depr, Fmt) & "."
``````