Creating a simple depreciation calculator
-
Greetings currently I'm having issues in developing a simple depreciation calculator. Basically I have two inputs Intial Cost and Salvage that can be entered via a textbox. My 3rd input is Years in which I called Life in my code basically I created a combobox in which users can select 1-20 years. Also I've created two radio buttons which enable a user to choose one of the two depreciation methods. I used SLN and SYD which are Straight Line and Sum of Years depreciation method. When all the inputs are entered and I press the calculate button I want the information to be displayed via ListView. However this is where my problem is. I'm not able to populate the ListView when I entered all my inputs. I think my event procedure (Calc) isn't correctly calling the general sub procedure. If anyone could provide some insight or general input on how to help make this calculator function. I'd be very greatful. Thank you for your time and I hope everyone is having a good week so far.
Public
Class Form1 Private Function SLN(ByVal Cost As Double, ByVal Salvage As Double, _ ByVal Life As Double) As Double Dim CalcDepre As Decimal Private Function SYD(ByVal Cost As Double, ByVal Salvage As Double, _ ByVal Life As Double, ByVal Period As Double) As Double Dim CalcDepre As Decimal Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click Dim Cost As Decimal Dim Salvage As Decimal Dim Years As Integer Dim Eqt As String Dim row As ListViewItemlvwDeprec.Items.Clear()
For Life = 1 To 20row = lvwDeprec.Items.Add(Life)
NextCost = Val(txtCost.Text)
Salvage = Val(txtSal.Text)
Life = Val(cboLife.Text)
If radStraight.Checked ThenEqt =
"SLN" End If If radSum.Checked ThenEqt =
"SYD" End IfUpdate = CalcDepre(Cost, Salvage, Eqt, Life)
End Sub Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click Me.Close() End SubEnd
Class -
Public Class Form1 </P> <P>Private Function SLN(ByVal Cost As Double, ByVal Salvage As Double, _
ByVal Life As Double) As Double
Dim CalcDepre As Decimal</P> <P> Private Function SYD(ByVal Cost As Double, ByVal Salvage As Double, _
ByVal Life As Double, ByVal Period As Double) As Double
Dim CalcDepre As Decimal</P> <P> Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim Cost As Decimal
Dim Salvage As Decimal
Dim Years As Integer
Dim Eqt As String
Dim row As ListViewItem</P> <P> lvwDeprec.Items.Clear()</P> <P> For Life = 1 To 20
row = lvwDeprec.Items.Add(Life)
Next</P> <P> Cost = Val(txtCost.Text)
Salvage = Val(txtSal.Text)
Life = Val(cboLife.Text)</P> <P> If radStraight.Checked Then
Eqt = "SLN"</P> <P> End If</P> <P> If radSum.Checked Then
Eqt = "SYD"
End If</P> <P> </P> <P>
Update = CalcDepre(Cost, Salvage, Eqt, Life)
End Sub</P> <P> Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class
Greetings My Code is incomplete as I'm unsure on how to proceed in effectively creating a simple depreciation calculator and ensure the results are displayed in the List view.Currently the Form I've created contains:
Intial Cost: TextBox
Salvage Value: TextBox
Life: ComboBoxStraight Line: RadioButton
Sum of Years: RadioButtonDisplay Result: ListView
Caculate: Button
Exit: Button
The user will enter in Intial Cost, Salvage Value, and select Life from dropdown list 1-20. After which they can select the depreciation calculation method via the radio button. Once caculate button is pressed the results show up in the List View. I hope you or anyone else will be able to help me through this complex issue. Thank you for your time -
Public Class Form1 </P> <P>Private Function SLN(ByVal Cost As Double, ByVal Salvage As Double, _
ByVal Life As Double) As Double
Dim CalcDepre As Decimal</P> <P> Private Function SYD(ByVal Cost As Double, ByVal Salvage As Double, _
ByVal Life As Double, ByVal Period As Double) As Double
Dim CalcDepre As Decimal</P> <P> Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim Cost As Decimal
Dim Salvage As Decimal
Dim Years As Integer
Dim Eqt As String
Dim row As ListViewItem</P> <P> lvwDeprec.Items.Clear()</P> <P> For Life = 1 To 20
row = lvwDeprec.Items.Add(Life)
Next</P> <P> Cost = Val(txtCost.Text)
Salvage = Val(txtSal.Text)
Life = Val(cboLife.Text)</P> <P> If radStraight.Checked Then
Eqt = "SLN"</P> <P> End If</P> <P> If radSum.Checked Then
Eqt = "SYD"
End If</P> <P> </P> <P>
Update = CalcDepre(Cost, Salvage, Eqt, Life)
End Sub</P> <P> Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class
Greetings XTab. My Code is incomplete as I'm unsure on how to proceed in effectively creating a simple depreciation calculator and ensure the results are displayed in the List view.Currently the Form I've created contains:
Intial Cost: TextBox
Salvage Value: TextBox
Life: ComboBoxStraight Line: RadioButton
Sum of Years: RadioButtonDisplay Result: ListView
Caculate: Button
Exit: Button
The user will enter in Intial Cost, Salvage Value, and select Life from dropdown list 1-20. After which they can select the depreciation calculation method via the radio button. Once caculate button is pressed the results show up in the List View. I hope you or anyone else will be able to help me through this complex issue. Thank you for your time -
Your code in the first post is difficult to follow. The code in your second and third posts is impossible to follow because it's just jumbled text. From what I can see in your first post you have two Functions...SLN and SYD. However, neither function has any code and neither one ever gets called. You've declared CalcDepre as a double in both those functions. However, in the button click event CalcDepre appears to be a function (which I can't find in your code anywhere). Here are a couple of tips.
1) Comment your code. This is good practice and will help someone like me figure out what's going on
2) When your posting code click on the HTML tab just above the post button. Then use the <pre></pre> tags to post your code. Everything in between these two tags will retain there formatting and will appear in a yellow box. This makes reading your code a whole lot easier.This is where your code would appear.
As I said from what I can tell I don't have enough of your code to figure out what's going on. It appears the code for the most important procedures are missing. Try posting all your code again taking into account my suggestions and hopefully we'll get to the bottom of this.
Post a reply
Quick links
Recent activity
- arif ahmad replied to How to receive data in web ...
- William Thompson replied to What is the name of the Win...
- Sameera Piyadigamage replied to Point of Sale Developers: H...
- Scott Carline replied to 4 x C# Developers for large...
- Rajendra Dhakal replied to Restore SQL Server text dat...
- cloud rainda replied to How to convert between TS f...
Enter your message below
Sign in or Join us (it's free).