|
-
Sep 20th, 2010, 07:07 PM
#1
Thread Starter
New Member
Problem with Do Loop
This code suppose to take the user's input of current balnace, the annual interest rate, the current month, and amount he/she will pay per month. When the CALCULATE button is clicked the program starting with the current month, should compute and display for each month until the balance is reduced to zero, the month, the interest charge, payment, and new balance. But somehow im stuck in an infinite loop and its not displaying anything. please help me
Code:
Public Class frmPaySchedule
Private Sub btncalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalculate.Click
Dim month As Integer = CInt(txtmonth.Text)
Dim balance As Decimal = CDec(txtbalance.Text)
Dim interest As Decimal = CDec(((txtAPR.Text / 100) / 12) * balance)
Dim payment As Decimal = CDec(txtpayment.Text)
Do Until balance = 0
If month = 5 Or month = 6 Or month = 7 Or month = 8 Then
payment = payment + 100
End If
If month = 11 Then
payment = payment + 50
End If
balance = balance - (payment - interest)
txtResult.Text = month.ToString & " " & FormatCurrency(interest) & " " & _
FormatCurrency(payment) & " " & FormatCurrency(balance)
month += 1
Loop
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|