0
タスクは、ユーザに元本金額を入力させ、コンボボックスから金利を選択させるとともに、その期間を選択させることです。 UIはラベルに月額支払いを表示するだけでなく、プリンシパルに向かって支払う金額と、複数行のテキストボックスでどのくらいの金利が利息に向かうのかを表示する必要があります。私はコードを完成させるのに問題があります。私はfinancial.ppmtメソッドをあまり入手していないのか、それとも毎月の支払いが正確に表示されていないだけでなく、複数行のテキストボックス情報(元本金額と金額)を表示することはできません正しく。誰かが助けてくれるか、少なくとも同様のプログラムに向けて私を指摘したら、私は大いに感謝します!financial.ppmtメソッドを使用したローン計算機
Option Explicit On
Option Strict On
Option Infer Off
Public Class MainForm
Private Sub ExitButton_Click(sender As Object, e As EventArgs) Handles ExitButton.Click
Me.Close()
End Sub
Private Sub CalcButton_Click(sender As Object, e As EventArgs) Handles CalcButton.Click
'Calculates the monthly payments on a loan using
'annual interest rates from 2%-10% and terms from 1-30 years
Dim Principal As Double
Dim term As Integer
Dim rate As Double
Dim monthlyPayment As Double
Dim interest As Double
'assign input to variables
Double.TryParse(PrincipalTextBox.Text, Principal)
term = Convert.ToInt32(TermComboBox.SelectedItem)
'clear text boxes
PaymentValue.Text = String.Empty
PrincipleAndInterestBox.Text = String.Empty
'calculate and display monthly payments
monthlyPayment = -Financial.Pmt(rate/12, 12, term * 12, Principal)
MonthlyPaymentLabel.Text = monthlyPayment.ToString("C2")
'Calculate the amount applied to principal and interest
For per As Integer = 12 To 1 Step -1
Principal = -Financial.PPmt(rate/12, per, 12, Principal)
interest = monthlyPayment - Principal
PrincipleAndInterestBox.Text = Principal.ToString("C2") & " " & interest.ToString("C2") & ControlChars.NewLine
Next per
PrincipleAndInterestBox.Focus()
End Sub
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles Me.Load
'fill termComboBox
For term As Integer = 1 To 30
TermComboBox.Items.Add(term.ToString)
Next term
TermComboBox.SelectedItem = "10"
'fill interestRateComboBox
For rate As Integer = 2 To 10
InterestRateComboBox.Items.Add(rate.ToString)
Next rate
InterestRateComboBox.SelectedItem = "4"
End Sub
エンドクラス