C
cw bebop
HTML code:
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" style="Z-INDEX: 105; LEFT: 120px; POSITION:
absolute; TOP: 64px" runat="server" Width="144px"></asp:TextBox>
<asp:TextBox id="TextBox2" style="Z-INDEX: 106; LEFT: 480px; POSITION:
absolute; TOP: 64px" runat="server"></asp:TextBox>
<aspropDownList id="DropDownList1" style="Z-INDEX: 107; LEFT: 320px;
POSITION: absolute; TOP: 16px" runat="server">
<asp:ListItem Value="Select Number...">Select Number...</asp:ListItem>
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
</aspropDownList>
<asp:Button id="Button1" style="Z-INDEX: 108; LEFT: 16px; POSITION:
absolute; TOP: 128px" runat="server" Text="COMPUTE"></asp:Button>
<DIV style="DISPLAY: inline; Z-INDEX: 109; LEFT: 448px; WIDTH: 56px;
POSITION: absolute; TOP: 16px; HEIGHT: 18px"
ms_positioning="FlowLayout"><FONT face="Verdana">YEARS</FONT></DIV>
<asp:Label id="Label1" style="Z-INDEX: 110; LEFT: 16px; POSITION:
absolute; TOP: 232px" runat="server"></asp:Label>
</form>
VS C# code behind I'm using:
private void Button1_Click(object sender, System.EventArgs e)
{
double amount;
string output = "";
int q;
if (DropDownList1.SelectedIndex > 0)
{
double ct = double.Parse(TextBox1.Text);
double salv = double.Parse(TextBox2.Text);
for (int i=1;i<DropDownList1.Items.Count;i++)
{
if (DropDownList1.Items.Selected)
{
string num= DropDownList1.Items.Value;
q = int.Parse(num);
for (int year=1; year<=q; year++)
{
amount = ct - (ct-salv)/year;
output += "AFTER " + (q-year+1) + " YEAR: " +"\t" + String.Format
("{0:C}", amount) + "<br>";
Label1.Text = output;
}
}
}
}
}
Problem(s):
Select a year from DropDownList, Enter the value 70000 for TextBox1 and
the value 10000 for TextBox2.
Would like the result to be
AFTER 1 YEAR: $58,000.00
AFTER 2 YEARS: $55,000.00
AFTER 3 YEARS: $50,000.00
AFTER 4 YEARS: $40,000.00
and so on...
Can anyone help correct my code to do this?
Is there anyway to use one For Loop instead of two in this code?
I'm looking for a simple solution.
Output should be:
After 1 year: any value
After 2 years: any value
After 3 years: any value
Thanks.
bebop
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" style="Z-INDEX: 105; LEFT: 120px; POSITION:
absolute; TOP: 64px" runat="server" Width="144px"></asp:TextBox>
<asp:TextBox id="TextBox2" style="Z-INDEX: 106; LEFT: 480px; POSITION:
absolute; TOP: 64px" runat="server"></asp:TextBox>
<aspropDownList id="DropDownList1" style="Z-INDEX: 107; LEFT: 320px;
POSITION: absolute; TOP: 16px" runat="server">
<asp:ListItem Value="Select Number...">Select Number...</asp:ListItem>
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
</aspropDownList>
<asp:Button id="Button1" style="Z-INDEX: 108; LEFT: 16px; POSITION:
absolute; TOP: 128px" runat="server" Text="COMPUTE"></asp:Button>
<DIV style="DISPLAY: inline; Z-INDEX: 109; LEFT: 448px; WIDTH: 56px;
POSITION: absolute; TOP: 16px; HEIGHT: 18px"
ms_positioning="FlowLayout"><FONT face="Verdana">YEARS</FONT></DIV>
<asp:Label id="Label1" style="Z-INDEX: 110; LEFT: 16px; POSITION:
absolute; TOP: 232px" runat="server"></asp:Label>
</form>
VS C# code behind I'm using:
private void Button1_Click(object sender, System.EventArgs e)
{
double amount;
string output = "";
int q;
if (DropDownList1.SelectedIndex > 0)
{
double ct = double.Parse(TextBox1.Text);
double salv = double.Parse(TextBox2.Text);
for (int i=1;i<DropDownList1.Items.Count;i++)
{
if (DropDownList1.Items.Selected)
{
string num= DropDownList1.Items.Value;
q = int.Parse(num);
for (int year=1; year<=q; year++)
{
amount = ct - (ct-salv)/year;
output += "AFTER " + (q-year+1) + " YEAR: " +"\t" + String.Format
("{0:C}", amount) + "<br>";
Label1.Text = output;
}
}
}
}
}
Problem(s):
Select a year from DropDownList, Enter the value 70000 for TextBox1 and
the value 10000 for TextBox2.
Would like the result to be
AFTER 1 YEAR: $58,000.00
AFTER 2 YEARS: $55,000.00
AFTER 3 YEARS: $50,000.00
AFTER 4 YEARS: $40,000.00
and so on...
Can anyone help correct my code to do this?
Is there anyway to use one For Loop instead of two in this code?
I'm looking for a simple solution.
Output should be:
After 1 year: any value
After 2 years: any value
After 3 years: any value
Thanks.
bebop
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!