코드에서 균형을 계산하는 데 약간의 문제가 있습니다.버튼의 코드에서 균형 잡기
이 프로그램에서는 (balance = balance * (1 + interestRate)
입니다. 것은 우리가 2013 년에 있고 저울은 사용자가 프로그램에서 클릭하는 체크 박스에 의해 선택되는 2015-2017 년 동안 계산 될 것이며, 또한 사용자는 그들이 가질 계정 유형을 선택합니다 (예 : 저축 : 7 %의 이익, 법인 : 5 %의이자).
그들은 mediaEstimatedFund
버튼을 클릭하고 그들이 선택한 계정 유형에 대한 잔액을 입력하도록 요청합니다 (저축, 법인 또는 둘 다). 그런 다음 선택한 금액 (년, 계정 및 잔액 금액)에 대한 잔액을 계산해야합니다. 여기
Year Savings Account Corporate Account Saving + Corporate
2013 $2000.00 $1000.00 $3000.00
2014 $2140.00 $1050.00 $3190.00
2015 $2289.8 $1102.5 $3392.3
2016 $2450.086 $1157.625 $3607.711
2017 $2621.59202 $1215.50625 $3837.09827
Public Class Form1
Private Sub btnMediaEstimatedFund_Click(sender As Object, e As EventArgs) Handles btnMediaEstimatedFund.Click
Dim interestRate, initialBalanceSavings, initialBalanceCorporate, finalBalance, theYear, balance, subTotal As Double
txtBoxEstimatedBudget.Enabled = False
txtBoxAgenciesNeeded.Enabled = False
If radButtonTraditional.Checked Then
txtBoxAgenciesNeeded.Text = 3
ElseIf radButtonEMedia.Checked Then
txtBoxAgenciesNeeded.Text = 2
End If
If checkBoxSavings.Checked Then
interestRate = 0.07
ElseIf checkBoxCorporate.Checked Then
interestRate = 0.05
ElseIf checkBoxCorporate.Checked And checkBoxSavings.Checked Then
interestRate = 0.12
End If
If radButton2015.Checked Then
theYear = 2015
End If
If radButton2016.Checked Then
theYear = 2016
End If
If radButton2017.Checked Then
theYear = 2017
End If
Dim inputtedData As String
If checkBoxSavings.Checked Then
Do
inputtedData = InputBox("Please enter a balance for SAVINGS account between $500.00 and $3000.00", "Initial Savings Balance", "0.00")
If inputtedData = "" Then
MsgBox("User chose to cancel calculation!")
Exit Sub
Else
initialBalanceSavings = CType(inputtedData, Single)
If initialBalanceSavings > 3000 Or initialBalanceSavings < 500 Then MsgBox("Please enter a balance for SAVINGS account equal to or above $500.00 and no more than $3000.00", MsgBoxStyle.Critical, "Error")
End If
Loop Until initialBalanceSavings >= 500 And initialBalanceSavings <= 3000
End If
If checkBoxCorporate.Checked Then
Do
inputtedData = InputBox("Please enter a balance for CORPORATE account between $500.00 and $3000.00", "Initial Corporate Balance", "0.00")
If inputtedData = "" Then
MsgBox("User chose to Cancel calculation!")
Exit Sub
Else
initialBalanceCorporate = CType(inputtedData, Single)
If initialBalanceCorporate > 3000 Or initialBalanceCorporate < 500 Then MsgBox("Please enter a balance for CORPORATE account equal to or above $500.00 and no more than $3000.00", MsgBoxStyle.Critical, "Error")
End If
Loop Until initialBalanceCorporate >= 500 And initialBalanceCorporate <= 3000
End If
finalBalance = initialBalanceSavings + initialBalanceCorporate
For theYear = 2013 To 2017
subTotal = finalBalance * (1 + interestRate)
finalBalance = subTotal
Next
txtBoxEstimatedBudget.Text = FormatCurrency(finalBalance)
End Sub
나에게 $ 2420.00을 준다. – Boom
나 ... 너는 어떻게 2621.6의 결과를 얻었 느냐? 귀하의 수식은 발생 된이자를 고려하지 않습니다. NewYears에서 코드를 업데이트 하시겠습니까? 2014 년에 2015 년을 확인해도 '시간 = 2'가 주어지지 않아야합니다. –
아니요, 업데이트하려고하지 않습니다 .... – Boom