|
I've been trying to a the number of loops inside a funtion and can't see to get it to work correctly. I've relook and reworked and nothing seems to correct the code. I would appreciate any help. It'd driving me crazy. I'm a novice at this and am trying to learn. Thanks for any input.
[code] <%@ Page Language="VB" debug="true" trace="True"%> <script runat="server">
Sub Page_Load If IsPostBack Dim Principal as Integer Dim Interest as Integer Dim FutureValue as Integer Dim YearCounter as Integer
YearCounter= CalcYear(TextBox1.text, TextBox2.Text,TextBox3.Text) YearCounter= Cdec(yearCounter) label1.text = YearCounter
End If End Sub
Function CalcYear (Principal as Integer, Interest as Integer, FutureValue as Integer) as decimal Dim YearCounter as Integer Yearcounter=1
Do trace.Write("NOTE - First Line of Loop") Principal += Principal * Interest YearCounter += 1 Loop Until FutureValue<Principal Return YearCounter End Function </script> <html> <head> </head> <body> <form runat="server"> <ASP:TEXTBOX id="TextBox1" runat="server"></ASP:TEXTBOX> Start Amount <br /> <ASP:TEXTBOX id="TextBox2" runat="server"></ASP:TEXTBOX> Interest Rate <br /> <ASP:TEXTBOX id="TextBox3" runat="server"></ASP:TEXTBOX> Future Amount <br /> <ASP:BUTTON id="Button1" runat="server" Text="Submit"></ASP:BUTTON> <br /> The number of years to goal is <asp:Label id="Label1" runat="server">Label</asp:Label> years. <br /> </form> </body> </html>
[/code}
|