WackoWolf
Active member
I have a form with a scrollbar that when click will show the amount of years in a textbox. The scrollbar works fine, but the calculation comes out wrong when i try it for 3 years. The formulas for the project is:
1. Yearly stright line decpreciation = (cost - salvage value)/5
2. Double declining depreciation = .4 * (cost - previous years depreciation)
3. Sum of the years digits depreciation = (6 - years)/15 * cost
Now when I do it for 3 years the declining balance depreciation should be 144 if the cost of the item is 1000, and the salvage is 100. The answer I get for the decliniing balance is 328 not 144. The depreciation is 200 which is right. Could someone tell me were my calculation is wrong, and what I need to do to fix it. I can't use a loop. Here is my code. Please help, been messing with this since Friday night.
Thank You
WackoWolf
1. Yearly stright line decpreciation = (cost - salvage value)/5
2. Double declining depreciation = .4 * (cost - previous years depreciation)
3. Sum of the years digits depreciation = (6 - years)/15 * cost
Now when I do it for 3 years the declining balance depreciation should be 144 if the cost of the item is 1000, and the salvage is 100. The answer I get for the decliniing balance is 328 not 144. The depreciation is 200 which is right. Could someone tell me were my calculation is wrong, and what I need to do to fix it. I can't use a loop. Here is my code. Please help, been messing with this since Friday night.
Thank You
WackoWolf
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ItemCost [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Decimal
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] SalvageValue [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Decimal
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Year [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Single
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] StraightLine [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Decimal
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] PreviousYear [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Decimal
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Declining [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Decimal
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Sum [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Decimal
[/COLOR][/SIZE][SIZE=2]ItemCost = TXTItemCost.Text
SalvageValue = TXTSalvageValue.Text
Year = TXTYear.Text
StraightLine = (ItemCost - SalvageValue) / 5
Declining = 0.4 * (ItemCost - StraightLine)
Sum = (6 - Year) / 15 * ItemCost
TXTStraightLine.Text = StraightLine
TXTDecliningBalance.Text = Declining
TXTDepreciationSum.Text = Sum
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]