# SYD 函數

SYD ( 成本、 殘餘、 生命週期

SYD函數語法具有下列引數：

 引數 描述 成本 所需。雙指定資產的原始成本。 殘餘 所需。Double，指定在其生命週期結尾資產的值。 生活 所需。雙指定資產的生命週期的長度。 期間 所需。雙指定期間內資產折舊的計算方式。

## 範例

``` Dim Fmt, InitCost, SalvageVal, MonthLife, LifeTime, DepYear, PDeprConst YEARMONTHS = 12 ' Number of months in a year.Fmt = "###,##0.00" ' Define money format.InitCost = InputBox("What's the initial cost of the asset?")SalvageVal = InputBox("What's the asset's value at the end of its life?")MonthLife = 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 = InputBox("What's the asset's useful life in months?")LoopLifeTime = MonthLife / YEARMONTHS ' Convert months to years.If LifeTime <> Int(MonthLife / YEARMONTHS) Then LifeTime = Int(LifeTime + 1) ' Round up to nearest year.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?"))LoopPDepr = SYD(InitCost, SalvageVal, LifeTime, DepYear)MsgBox "The depreciation for year " & DepYear & " is " & Format(PDepr, Fmt) & "." ```

×