I a sorry to come back with the same question.

2014 $5500 $5000.00 28% (10/12) x (5/15) $1389 $1389 $4111
2015 $4,111 $5,000.00 28% [(2/12) x (5/15)] + [(10/12) x (4/15)] $1,389 $2,778 $2,722

below is the code i use to calculate for the sum of years digit depreciation which start from the first month of the year to last which is okay for me. but what i want now is, let say we are already done with two (2) months remaining ten (10) month. How can i compute like the 2 examples above.

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim Cost, Scrap, Life, Period, BegValue, EndValue, Deprec, AccumDeprec, YearPurch As Double
    Dim Fmt As String = "###,##0.00"

    Cost = TxtCost.Text
    Scrap = txtscrap.Text
    Life = TxtLife.Text
    YearPurch = txtYear.Text
    Period = TxtLife.Text



    DataGridView1.ColumnCount = 6
    DataGridView1.Columns(0).Name = "Begin Year"
    DataGridView1.Columns(1).Name = "Begin Value"
    DataGridView1.Columns(2).Name = "Depreciation"
    DataGridView1.Columns(3).Name = "Accum.Depreciation"
    DataGridView1.Columns(4).Name = "End Value"
    DataGridView1.Columns(5).Name = "End Year"

    DataGridView1.Rows.Clear()

    BegValue = Cost

    For Period = 1 To Life

        Deprec = SYD(Cost, Scrap, Life, Period)
        AccumDeprec += Deprec
        EndValue = BegValue - Deprec

        Dim row As String() = New String() {YearPurch, _
                                             FormatNumber(BegValue), _
                                             FormatNumber(Deprec), _
                                             FormatNumber(AccumDeprec), _
                                             FormatNumber(EndValue), _
                                             YearPurch}



        DataGridView1.Rows.Add(row)

        BegValue = EndValue


        If Period = Life - 1 Then

            Deprec = BegValue - Scrap

        Else

            Deprec = SYD(Cost, Scrap, Life, Period)

        End If

        YearPurch += 1

    Next

End Sub

End Class

How do the values in your examples correspond to the variables in your code or the columns in your datagridview? What does SYD do?

Each variable correspond to a textbox value and the SYD is the VB.net and excel function to perform the sum of year's digit computation. What I want is that, suppose an asset was bought in February. That means one month is past and remaining eleven months to go and the asset will used in within 5 years. So to compute the SYD for the asset in 5 year, it sholud be (11/12) * (5/15) * (asset cost - salvage). I want a looping code in vb.net to do all these for me. The above code works fine but with limitation. And the limitation is what i have explained to you. Thanks for your concern.

But that doesn't help anyone figure out which values correspond to which variables. For instance is $5500 cost, begvalue, endvalue, etc.? Your example has eight fields but your code shows nine variables and only five textboxes, so what corresponds to what?

Please add comments to you codes and repost the code with comments which start what each line does so that it will be easy for us to follow and see where you stuck and help you because so far I don't get straight what you want to achieve even though I get a little bit when you try to explain but you just get me lost other than before when you start adding the numbers, I'm really not clear what exactly you want. What I think you are trying is to determine a passed month and subtract 1 from 12 which is 12 months each and every time the month ends up to 12 month Right? If I'm correct now is you time to explain about the $ what exactly you want to do with it and which variable holds which $ value on your code. Please explain that I'm sure once you have done that it will be easy for us to help you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.