ASP.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a ASP.NET Expert!

Join 300,427 ASP.NET Programmers for FREE! Get instant access to thousands of ASP.NET experts, tutorials, code snippets, and more! There are 1,494 people online right now. Registration is fast and FREE... Join Now!




Counting Loops in a Function

 

Counting Loops in a Function

beesmond

28 Jun, 2009 - 03:46 PM
Post #1

New D.I.C Head
*

Joined: 26 Jun, 2009
Posts: 1

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>
&nbsp; Start Amount
<br />
<ASP:TEXTBOX id="TextBox2" runat="server"></ASP:TEXTBOX>
&nbsp; Interest Rate
<br />
<ASP:TEXTBOX id="TextBox3" runat="server"></ASP:TEXTBOX>
&nbsp; 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>&nbsp;years.
<br />
</form>
</body>
</html>

[/code}

User is offlineProfile CardPM
+Quote Post


brainfreeze

RE: Counting Loops In A Function

29 Jun, 2009 - 04:46 AM
Post #2

New D.I.C Head
*

Joined: 28 May, 2009
Posts: 6

Try something similar to:
CODE

While futurevalue < Principal
        Principal += Principal * Interest
        YearCounter + 1
Next

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 12:24AM

Live ASP.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

ASP.NET Tutorials

Reference Sheets

ASP.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month