帮助vb.net中的双倍下降余额折旧 [英] Help on Double Decline Balance Depreciation in vb.net

查看:105
本文介绍了帮助vb.net中的双倍下降余额折旧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我使用的vb.net代码来计算Double Decline Balance Depreciation,它可以很好地处理小错误计算。问题是Accum.Depreciation的最后一列中的值假设为5000但不是。这里的问题是2018年的开始时间是712.20,它必须从废料值中减去,而不是乘以0.4,这将是285.12,然后将该数字加到4,787.20,这给了我(5,072.32),这是错误的。我尽我所能,但问题仍然存在。我希望我的结果像table-2而不是tbale-1。请有人帮忙。 非常紧急。



表-1

Below is my vb.net code i use to calculate Double Decline Balance Depreciation which work fine with a small error calculation. The problem is that the value in the last column of Accum.Depreciation suppose to be 5000 but not. The proble here is beginval of 2018 which is 712.20 which has to be subtract from the scrap value is rather multiplying by 0.4 which will be 285.12 and that figure is then added to 4,787.20 which give me this (5,072.32) and that is wrong. I try all what I could but problem still exit. I want my result to be like table-2 not tbale-1. Please some one has to help. Is very urgent.

Table-1

Year	Begin Value	Depreciation	Accum. Depreciation	End Value
2014	5,500	         2,200	         2,200	                 3,300
2015	3,300	         1,320	         3,520	                 1,980
2016	1,980	           792	         4,312	                 1,188
2017	1,188	           475.20	 4,787.20	           712.80
2018	712.80	           212.80	 5,072.32	           500







表-2




Table-2

Year	Begin Value	Depreciation	Accum. Depreciation	End Value
2014	5,500	         2,200	         2,200	                 3,300
2015	3,300	         1,320	         3,520	                 1,980
2016	1,980	           792	         4,312	                 1,188
2017	1,188	           475.20	 4,787.20	           712.80
2018	712.80	           212.80	 5,000	                   500







Private Sub DoubleDecline()

        Dim yearpurchased, cost, scrap, life, Deprec, Accumdeprec, begvalue, endgvalue As Double
        Dim item As String
        Dim fmt As String = {0,-7}{1,10}{2,16}{3,20}{4,20}
        Dim numberyears As Integer

        item = txtItem.Text
        yearpurchased = txtYear.Text
        cost = TxtCost.Text
        scrap = txtscrap.Text
        life = TxtLife.Text

        listDepreciation.Items.Clear()
        listDepreciation.Items.Add(" ")

        listDepreciation.Items.Add(String.Format(fmt, "Year", "Beg of Yr", "During Year", "Accum Deprec", "to End of Year"))



        begvalue = cost
        Deprec = (begvalue * 0.4)
        Accumdeprec = (Accumdeprec + Deprec)
        endgvalue = begvalue - Deprec

        For numberyears = 1 To life
            listDepreciation.Items.Add(String.Format(fmt, _
                            yearpurchased, _
                            FormatNumber(begvalue), _
                            FormatNumber(Deprec), _
                            FormatNumber(Accumdeprec), _
                            FormatNumber(endgvalue)))

            begvalue = endgvalue
            Deprec = (endgvalue * 0.4)
            Accumdeprec = (Accumdeprec + Deprec)
            endgvalue = begvalue - Deprec

            If numberyears = life - 1 Then

                Deprec = begvalue - scrap

                endgvalue = begvalue - Deprec

            End If
            yearpurchased = yearpurchased + 1
        Next


    End Sub

推荐答案

嗯我认为你的算法有问题,当你测试边缘情况数字年=生命 - 1.

这应该更像:

Well I think there is something wrong with your algorithm, when you test for the edge-case numberyears = life - 1.
This should be more like:
For numberyears = 1 To life
   listDepreciation.Items.Add(String.Format(fmt, _
                                            yearpurchased, _
                                            FormatNumber(begvalue), _
                                            FormatNumber(Deprec), _
                                            FormatNumber(Accumdeprec), _
                                            FormatNumber(endgvalue)))

   begvalue = endgvalue

   If numberyears = life - 1 Then
      Deprec = begvalue - scrap
   Else
      Deprec = (endgvalue * 0.4)
   End If

   Accumdeprec += Deprec
   endgvalue = begvalue - Deprec

   yearpurchased += 1
Next





希望这会有所帮助。



Hope this helps.


请阅读该问题的所有评论。您没有提供有关您的问题的足够信息。



我强烈建议您按照这些说明操作:启动,中断,步骤,运行代码,并在Visual Studio中停止调试 [ ^ ]查找错误。
Please read all comments to the question. You didn't provide enough information about your issue.

I'd strongly recommend you to follow these instructions: Start, Break, Step, Run through Code, and Stop Debugging in Visual Studio[^] to find a bug.


这篇关于帮助vb.net中的双倍下降余额折旧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆