Results 1 to 3 of 3

Thread: 10 year pay caculator (calculation problem)

  1. #1
    New Member
    Join Date
    Jul 12
    Posts
    3

    10 year pay caculator (calculation problem)

    Dim decwage As Decimal
    Dim decraise As Decimal
    Dim decWagePerYear As Decimal


    For intYear As Integer = 1 To 10

    If Decimal.TryParse(txtHourlyWage.Text, decwage) AndAlso Decimal.TryParse(txtRaise.Text, decraise) Then
    decWagePerYear += decwage * 2080
    decwage *= (decraise / 100)
    LstYearPay.Items.Add(" Year " & intYear & " Annual Salary " & decWagePerYear)
    End If
    Next

    I'm trying to get this code to add the difference in pay for the next 10 years. Unfortunately it is taking the percent and multiplying that by the pay for the year. Can anyone help me with what I'm doing wrong.

  2. #2
    vb Coda .paul.'s Avatar
    Join Date
    May 07
    Location
    Chelmsford UK
    Posts
    16,464

    Re: 10 year pay caculator (calculation problem)

    the first problem i can see is your loop is in the wrong place:

    vb.net Code:
    1. Dim decwage As Decimal
    2. Dim decraise As Decimal
    3. Dim decWagePerYear As Decimal
    4.  
    5. If Decimal.TryParse(txtHourlyWage.Text, decwage) AndAlso Decimal.TryParse(txtRaise.Text, decraise) Then
    6.     For intYear As Integer = 1 To 10
    7.         decWagePerYear += decwage * 2080
    8.         decwage *= (decraise / 100)
    9.         LstYearPay.Items.Add(" Year " & intYear & " Annual Salary " & decWagePerYear)
    10.     Next
    11. End If

  3. #3
    New Member
    Join Date
    Jul 12
    Posts
    3

    Re: 10 year pay caculator (calculation problem)

    Thanks for that. Now that I have corrected the place of the loop, when I hit the calculate button I get all sorts of crazy numbers is the way I setting up the calculations not acceptable?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •