I am writing a program that I think I am getting an infinite loop on. Can’t seem to figure out where. I am sure it is more than likely the first loop being done. Anyway so you know what I am trying to do. I am asking for someone to enter an amount they are “depositing” into an account that is compiled annually by an interest also provided by the user. From that information I am to determine how long it will take for that initial amount of money to double and how long it is to take to make a million dollars. Every time I run the program it freezes up on me any help provided is much appreciated. Here is my code.
Private Sub btnDetermine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDetermine.Click 'Declare Variables Dim balance, r As Double Dim numYearsMil As Integer Dim numYearsDoub As Integer 'Get initial value of balance, and rate from a textbox balance = CDbl(txtAmount.Text) r = CDbl(txtRate.Text) 'Loop determines the number of years it will take to double your money Do While balance = (balance * 2) 'Prints the number of years it takes to double your money txtDouble.Text = "in " & numYearsDoub & " years you will double your money." 'Loop determins the number of years it will take to become a millionare Do While balance < 1000000 balance += r * balance numYearsMil += 1 Loop 'Prints the number of years it takes to become a millionare txtMillion.Text = "In " & numYearsMil & " years you will have a million dollars." End Sub