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