# DDB 函数

DDB ( 成本、 残、 生活、 期 [、 因素] )

DDB函数语法具有以下参数：

 参数 说明 成本 必填。双指定资产的初始成本。 资产残 必填。双指定值末尾的年限资产。 生活 必填。双指定长度的资产的生命周期。 时间段 必填。双指定期间内资产被计算的折旧值。 系数 可选。Variant 值，指定的余额递减的速率。如果省略，则假定 2 （双倍余额递减法）。

DDB函数使用以下公式计算在给定期间内的折旧值：

## 示例

``` Dim Fmt, InitCost, SalvageVal, MonthLife, LifeTime, DepYear, DeprConst 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?")LoopLifeTime = 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.")LoopDepr = DDB(InitCost, SalvageVal, LifeTime, DepYear)MsgBox "The depreciation for year " & DepYear & " is " & _Format(Depr, Fmt) & "." ```

×