- Aug 31, 2001
- 35,560
- 22
- 81
Ok so I have my loop and the rest of my program working just fine, but I dont know how to incorporate a certain line or even what code to put in. What I need is for the number of years it took for the principle to double to be displayed in a label. I have attached the code. Can someone please help me with setting up code so that I can tell how many years it takes for the principle to double? thanks in advance
For n = 1 To years Step 1 'loop used to calculate yearly compounded dividends
d = Rate * Principle 'Calculates dividends
Principle = Principle + d ' calculates total principle per year
totald = totald + d ' calculates total dividends earned over time
txtOutput.Text = txtOutput.Text & rightalign(n, cfYearwidth) & rightalign(Format(d, "$0.00"), cfDividendwidth) & rightalign(Format(Principle, "$0.00"), cfBal) & rightalign(Format(totald, "$0.00"), cfAccum) & vbCrLf
Next n
For n = 1 To years Step 1 'loop used to calculate yearly compounded dividends
d = Rate * Principle 'Calculates dividends
Principle = Principle + d ' calculates total principle per year
totald = totald + d ' calculates total dividends earned over time
txtOutput.Text = txtOutput.Text & rightalign(n, cfYearwidth) & rightalign(Format(d, "$0.00"), cfDividendwidth) & rightalign(Format(Principle, "$0.00"), cfBal) & rightalign(Format(totald, "$0.00"), cfAccum) & vbCrLf
Next n
