Below code is working fine with small problem. My problem here is, how can i get the BegValue working in a proper order. please it is only the begvalue that is giving me a headache. Please some one help me. !!!

Thanks in advance.

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()

    For Period = 1 To Life

        BegValue = Cost
        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

What is the problem that you are having? What is the formula that you are using to calculate the values?

What I think is that move all the calculation above the "line 31. Dim row As String
() = New String()" because what I see is that before you calculate the BegValue you add everything to a database and the just below or after you added things to the database you then calculate the BagValue so as you save it, it has the Cost values so to get the correct results also try to remove this assign BegValue = Cost just use cost straight there because you used twice begvalue and only use it here:" line 42. BegValue =
EndValue" and see.

I was able to solve it yesterday by my self and thank you for your advice.

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

This question has already been answered. Start a new discussion instead.