VB beginner here. My For... Next Loop will not work and I cannot for the life of me figure out why. I have tried to display the results in a label and a text box with multiline enabled. Doesn't seem to matter. It's probably something obvious I have been overlooking for 2 hours. Thanks in advance for any help.
Option Explicit On
Option Strict On
Option Infer Off
Public Class Form1
Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub displayButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles displayButton.Click
Dim monthly As Double
Dim results As Double
Dim interest As Double
''#clear textbox results
displayLabel.Text = String.Empty
monthlyTextBox.Text = String.Empty
''#calculate the monthly payment due
monthly = -Financial.Pmt(0.06 / 12, 12, 5000)
monthlyTextBox.Text = monthly.ToString("C2")
''#calculate the amounts applied to principal and interest
For per As Integer = 12 To 1 Step -1
results = -Financial.PPmt(0.06 / 12, per, 12, 5000)
interest = monthly - results
displayLabel.Text = results.ToString("C2") & " " & interest.ToString("C2") & ControlChars.NewLine
Next per
displayLabel.Focus()
End Sub
End Class