1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: VB double-declining-balance help pls

Discussion in 'Software Development' started by Coke23, May 7, 2010.

Thread Status:
Not open for further replies.
Advertisement
  1. Coke23

    Coke23 Thread Starter

    Joined:
    Mar 24, 2010
    Messages:
    12
    i need help with this project. I wrote the code but im getting errors. i dont know what im doing wrong. it wont calculate .can anybody help and fix my code thanks.
    this is the project

    For tax purposes an item may be depreciated over a period of several years, n. With the straight-line method of depreciation, each year the item depreciates by l/nth of its original value. With the double-declining-*balance method of depreciation, each year the item depreciates by 2/nths of its value at the beginning of that year. (In the last year, it is depreciated by its value at the beginning of the year.) Write a program that performs the following tasks:

    (a) Requests a description of the item, the year of purchase, the cost of the item, the number of years to be depreciated (estimated life), and the method of depreciation. The method of depreciation should be chosen by clicking one of two buttons.

    (b) Displays a depreciation schedule for the item similar to the schedule shown below:
    Description: Computer
    Year of purchase: 2008
    Cost: $2,000.00
    Estimated life: 5
    Method of depreciation: double-declining-balance



    Value at Amount Deprec Total Depreciation

    Year Beg of Yr During Year to End of Year

    2008 2,000.00 800.00 800.00

    2009 1,200.00 480.00 1,280.00

    2010 720.00 288.00 1,568.00

    2011 432.00 172.80 1,740.80

    2012 259.20 259.20 2,000.00
     
  2. Coke23

    Coke23 Thread Starter

    Joined:
    Mar 24, 2010
    Messages:
    12
    This is my code

    Public Class Project4
    Dim dblCost, dblLife, dblYear, DblDepreciation, dblBegValue, dblEndValue, dblTotal, Counter
    Private Sub lstOutput_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstOutput.SelectedIndexChanged

    End Sub

    Private Sub btnStraight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStraight.Click


    ' Setting Columns, minus sign indicates left justification, default is right justification
    Dim fmtSTR As String = "{0,-22}{1,22}{2,22}{3,22}{4,22}"


    'Declare Variables
    dblCost = Val(txtCost.Text)
    dblLife = Val(txtLife.Text)
    dblYear = Val(txtYear.Text)



    'Info for List Box
    lstOutput.Items.Clear()
    lstOutput.Items.Add("Depscription" & txtDescription.Text)
    lstOutput.Items.Add("Year of Purchase:" & txtYear.Text)
    lstOutput.Items.Add("Cost:" & txtCost.Text)
    lstOutput.Items.Add("Estimated Life:" & txtLife.Text)
    lstOutput.Items.Add("Method of Deprection: Straight Line")

    'Titles for Table in List Box
    lstOutput.Items.Add(String.Format(fmtSTR, "Year", "Value at Beg.of Year", "Annual Deprec", "Value at End of Yr.", "Total Depreciation"))

    'Declare Loop Counters
    Dim intA As Integer




    'For Figuring Depreciation
    DblDepreciation = dblCost / dblLife


    'Fpr Figuring Begining Value
    dblBegValue = dblCost
    Counter = dblCost - DblDepreciation



    'Loop for Straight Life Depreciation
    For intA = 1 To dblLife
    lstOutput.Items.Add(dblYear)



    dblBegValue = dblCost - DblDepreciation
    lstOutput.Items.Add(" ")

    dblTotal = dblCost - dblEndValue



    dblEndValue = dblBegValue - DblDepreciation
    Next



    End Sub

    Private Sub btnDouble_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDouble.Click

    ' Setting Columbs, minus sign indicates left justification, default is right justification
    Dim fmtSTR As String = "{0,-22}{1,22}{2,22}{3,22}{4,22}"

    'Declare Variables
    dblCost = Val(txtCost.Text)
    dblLife = Val(txtLife.Text)
    dblYear = Val(txtYear.Text)



    'Info for List Box
    lstOutput.Items.Clear()
    lstOutput.Items.Add("Depscription" & txtDescription.Text)
    lstOutput.Items.Add("Year of Purchase:" & txtYear.Text)
    lstOutput.Items.Add("Cost:" & txtCost.Text)
    lstOutput.Items.Add("Estimated Life:" & txtLife.Text)
    lstOutput.Items.Add("Method of Deprection: Double Declining")


    'Titles for Table in List Box
    lstOutput.Items.Add(String.Format(fmtSTR, "Year", "Value at Beg.of Year", "Annual Deprec", "Value at End of Yr.", "Total Depreciation"))


    DblDepreciation = dblCost / dblLife
    dblBegValue = dblCost - DblDepreciation
    dblEndValue = dblBegValue - DblDepreciation
    dblTotal = dblCost - dblEndValue







    End Sub


    End Class
     
  3. Coke23

    Coke23 Thread Starter

    Joined:
    Mar 24, 2010
    Messages:
    12
    i got the answer i needed
     
  4. ermcse

    ermcse

    Joined:
    May 15, 2010
    Messages:
    1
    what was your final code?
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/921559

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice