日期:2010-04-30 浏览次数:20435 次
Public Function CalcBalance(ByVal Prncpl As Integer, _ ByVal Rate As Double, _ ByVal Years As Integer, _ ByVal Period As Integer) As String Dim BaseNum As Double = (1 + Rate / Period) CalcBalance = _ Format(Prncpl * System.Math.Pow(BaseNum, _ (Years * Period)), "#,###,##0.00").ToStringEnd Function
<%@ page language="VB" %><script runat="server"> Sub Button1_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Dim Calc As New CalculateInterest Label6.Text = "$" & _ Calc.CalcBalance(Convert.ToInt32(TextBox1.Text), _ (Convert.ToInt32(TextBox2.Text) / 100), _ Convert.ToInt32(TextBox3.Text), _ Convert.ToInt16(Dropdownlist1.SelectedValue)) Label6.Visible = True End Sub</script><html><head runat="server"> <title> 利息计算器</title></head><body> <form runat="server"> <asp:label id="Label1" runat="server">P本金 ($):</asp:label> <asp:textbox id="TextBox1" runat="server"> </asp:textbox> <br /> <asp:label id="Label2" runat="server">利率 (%):</asp:label> <asp:textbox id="TextBox2" runat="server"> </asp:textbox> <br /> <asp:label id="Label3" runat="server">年数:</asp:label> <asp:textbox id="TextBox3" runat="server"> </asp:textbox> <br /> <asp:label id="Label4" runat="server">复利频率:</asp:label> <asp:dropdownlist id="Dropdownlist1" runat="server"> <asp:ListItem Value="1">每年</asp:ListItem> <asp:ListItem Value="4">每季</asp:ListItem> <asp:ListItem Value="12">每月</asp:ListItem> <asp:ListItem Value="365">每日</asp:ListItem> </asp:dropdownlist> <br /> <asp:label id="Label5" runat="server">结余: </asp:label> <asp:label id="Label6" visible="false" runat="server"></asp:label> <br /> <asp:button id="Button1" runat="server" text="计算" /> </form></body></html>