Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42728

Loop for years and calculations

$
0
0
Here some code from my program that calculates depreciation. All the calculations work except my the TOTAL calculation and my loop to go up a year with each year that is selected. So what I need help is finding the right code for the loop and then the right formula for the TOTAL calculation.

Code:

  Dim YearOf As Double
    Dim Cost As Double
    Dim Estimate As Double
    Dim Depreciation As Double
    Dim Total As Double
    Dim SalvageValue As Double = 0.0
    Dim BeginValue As Double
    Dim Straight As Integer
    Dim DoubleDeclining As Double
    Dim Balance As DoubleFor YearOf = 1 To CInt(Estimate)

            ''For loop for continuation of years and depreciation
            BeginValue = BeginValue / 2
            Depreciation = Depreciation / 2
            Total = Depreciation - Rate

            ''Calculate balance at start of year, accumulated depreciation at end of year and balance at end of year
            lstTotals.Items.Add("Value at beginning of " & (CDbl(txtPurchaseYear.Text) + 1) & ": " & FormatCurrency(BeginValue))
            lstTotals.Items.Add("Amount of depreciation during " & (CDbl(txtPurchaseYear.Text) + 1) & ": " & FormatCurrency(Depreciation))
            lstTotals.Items.Add("Total depreciation at the end of " & (CDbl(txtPurchaseYear.Text) + 1) & ": " & FormatCurrency(Total))
            lstTotals.Items.Add("")

        Next

Here are the instructions I was given to figure out the total but I can't seem to figure it out:

Depreciation Year #1:
Initial cost year #1 = $1,000
Amount of depreciation = $500 (which is 50% x $1,000)
The balance to be depreciated over the next 3 years is $500 ($1,000 initial
cost - $500 depreciation in year 1)
Depreciation Year #2:
Remaining cost to depreciate $500
Amount of depreciation = $250 (which is 50% x $500)
The balance to be depreciated over the next 2 years is $250 ( $500 – 250)
Depreciation Year #3:
Remaining cost to depreciate $250
Amount of depreciation = $125 (which is 50% x $250)
The balance to be depreciated over the next 2 years is $125 ( $250 – 125)
Depreciation Year #4:
Remaining cost to depreciate $125
Since this is the last year of depreciation, the remaining $125 is
depreciated.

Please help!

Viewing all articles
Browse latest Browse all 42728

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>