need help!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ed5195
    New Member
    • Oct 2013
    • 3

    need help!

    this for loop runs a set number of times. it is used to execute a group of lines repeatedly. computing the monthly loan payment is a good demonstration for a loop. the monthly loan payment is a fixed sum that is composed of both interest and principle repayment.

    Please help me!


    Code:
    Public Class Form1
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim loan As Single = Val(TextBox1.Text)
            Dim interest As Single = 9%
            Dim numberofyears As Single = Val(TextBox2.Text)
            Dim monthlypayment, monthlyrate, numberofpayments, count As Single
            monthlyrate = 1 + (interest / (12 * 100))
            numberofpayments = numberofyears * 12
            monthlypayment = (loan * interest * monthlyrate ^ numberofpayments) / (1200 * ((monthlyrate ^ numberofpayments) - 1))
    
            Dim interestpart, loanpart, Balance As Single
            For count = 1 To numberofpayments
                interestpart = loan * (interest * 9) / 12
                loanpart = monthlypayment - interestpart
                Balance = loan - loanpart
            Next
            Dim paymentoutput As Single
            Label1.Text = paymentoutput & "Payment #" & count & vbTab & _
            Format(loan, "C") & " " & vbTab & FormatCurrency(interestpart) & vbTab & _
            FormatCurrency(loanpart) & vbTab & FormatCurrency(Balance) & vbCrLf
        End Sub
    End Class
    Last edited by Rabbit; Nov 1 '13, 12:43 AM. Reason: Fixed code tags
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    What do you need help with? All you've done is describe what the For loop does.

    Comment

    Working...