Really need some help with the code below. How to I convert the financial.ddb method to give me an outoput calculation equal to the method... when I run the code, my label only shows 0 when I should be getting some kind of calculation. Financial.ddb is basically Depreciation / Period = ((Cost – Salvage) * Factor) / Life
My code uses a list box for life and I have a feeling that this is the culprit... can someone PLEASE help!
code
Public Class Form1
Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim code As Integer = 3
Do While code <= 20
lifeListBox.Items.Add(code.ToString)
code = code + 1
Loop
lifeListBox.Items(0) = 3
lifeListBox.Items(1) = 4
lifeListBox.Items(2) = 5
lifeListBox.Items(3) = 6
lifeListBox.Items(4) = 7
lifeListBox.Items(5) = 8
lifeListBox.Items(6) = 9
lifeListBox.Items(7) = 10
lifeListBox.Items(8) = 11
lifeListBox.Items(9) = 12
lifeListBox.Items(10) = 13
lifeListBox.Items(11) = 14
lifeListBox.Items(12) = 15
lifeListBox.Items(13) = 16
lifeListBox.Items(14) = 17
lifeListBox.Items(15) = 18
lifeListBox.Items(16) = 19
lifeListBox.Items(17) = 20
End Sub
Private Sub DDSButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DDSButton1.Click
Dim cost As Double
Dim life As Double
Dim period As Double
Dim salvage As Double
Dim depreciation As Double
Dim isConvertedCost As Boolean
Dim isConvertedLife As Boolean
Dim isConvertedSalvage As Boolean
Dim depriciation As Double
isConvertedCost = Double.TryParse(assetcostTextBox.Text, cost)
isConvertedLife = Double.TryParse(lifeListBox.Text, life)
isConvertedSalvage = Double.TryParse(salvagevalueTextBox.Text, salvage)
If isConvertedCost AndAlso isConvertedLife AndAlso isConvertedSalvage Then
dsoutTextBox.Text = " Year Depreciation"
For Year As Double = 0.01 To 0.05 Step 0.01
depriciation = Financial.DDB(cost, salvage, life, 1, 2.0)
dsoutTextBox.Text = dsoutTextBox.Text & ControlChars.NewLine & Year.ToString("P0") & depreciation.ToString("C2")
Next Year
dsoutTextBox.Focus()
/code
Thank you!