I'm a beginner at using visual basic and I'm having trouble displaying my years correctly in my application. My application should display Rates: 3% - 7%, then under each rate Years should display: 1-5 and Balance should display a total amount per year. What I'm getting is 3% rate, years 1-5, and balance for each year. 4% rate is getting year 6, instead of 1-5 and balance for year six. 5% Rate is displaying year 7 and balance for that year, and so on. FYI: I need to keep the For...Next statement and incorporate a Do...Loop statement for "Years."
I inserted pics for a better understanding of what I'm trying to explain. I'd appreciate any help.
Here is the code:
Dim dblDeposit As Double
Dim dblBalance As Double
Dim intYear As Integer = 1
Double.TryParse(txtDeposit.Text, dblDeposit)
txtBalance.Text = "Rate" & ControlChars.Tab &
"Year" & ControlChars.Tab & "Balance" &
ControlChars.NewLine
' Calculate and display account balances.
For dblRate As Double = 0.03 To 0.07 Step 0.01
txtBalance.Text = txtBalance.Text &
dblRate.ToString("P0") & ControlChars.NewLine
Do
dblBalance = dblDeposit * (1 + dblRate) ^ intYear
txtBalance.Text = txtBalance.Text &
ControlChars.Tab & intYear.ToString &
ControlChars.Tab & dblBalance.ToString("C2") &
ControlChars.NewLine
intYear = intYear + 1
Loop While intYear < 6
Next dblRate