views:

120

answers:

2

For example, input values are Cost = 1250, Salvage = 150, Life 5. Then the output I want is:
$500.00
$300.00
$180.00
$108.00
$12.00
However, the program outputs:
$500.00
$500.00
$500.00
$500.00
$500.00
P.S. This is for the DDB
Also, how could I add numbers before each values like
1 $500.00
2 $300.00
3 $180.00
4 $108.00
5 $12.00

Thank you!!

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Button1.Text = ("SLN")
        Button2.Text = ("DDB")
        Button3.Text = ("SYD")
        Button4.Text = ("Quit")
        Label1.Text = ("Cost")
        Label2.Text = ("Salvage")
        Label3.Text = ("Life")

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim Cost As Double = CDbl(TextBox1.Text)
        Dim Salvage As Double = CDbl(TextBox2.Text)
        Dim Life As Double = CDbl(TextBox3.Text)
        Dim List As Double = SLN(Cost, Salvage, Life)
        ListBox1.Items.Add(FormatCurrency(List))

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim Cost As Double = CDbl(TextBox1.Text)
        Dim Salvage As Double = CDbl(TextBox2.Text)
        Dim Life As Double = CDbl(TextBox3.Text)
        Dim List As Double = DDB(Cost, Salvage, Life)
        For i = 1 To Life
            ListBox1.Items.Add(FormatCurrency(List))
        Next
    End Sub

    Function SLN(ByVal Cost As Double, ByVal Salvage As Double, ByVal Life As Integer) As Double

        Dim Value As Double
        Value = (Cost - Salvage) / Life
        Return Value

    End Function

    Function DDB(ByVal Cost As Double, ByVal Salvage As Double, ByVal Life As Integer) As Double

        Dim Value As Double
        Value = Cost * 2 / Life
        Cost = Cost - Value
        Return Value

    End Function

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        End

    End Sub

End Class

I finally figured out what the problem was!!! :) You don't have to provide an answer any more. Thanks.

A: 

just out of curiousity, how did you end up fixing the problem?

john
I got rid of the variable 'List' then directly used 'SLN(Cost, Salvage, Life)'. If you want, now that the due date for this assignment is over, I could post the code.
Woong-Sup Jung
A: 

hi there? u taking cmpt110 in sfu?

yes. are you too?
Woong-Sup Jung