Automobile Loan Calculator

来源:互联网 发布:grpc java实现 编辑:程序博客网 时间:2024/05/13 21:27
'学习心得'运算符的优先级'变量名的制定:g(是否是全局)+数据类型+变量=变量名;gdblName' AcceptButton Property of the Form specifies this button.When the user press the Enter key or clicks the default button on a form that has the AcceptButton property set.''MonthlyPayment = (InterestRate*(1+InterestRate)^NumberOfPayments)/((1+InterestRate)^NumberOfPayments-1)*LoanAmount 这个在   “Pmt Founction ”  里面有'Format Function 将日期,时间等转换成专用的格式Option Strict OnPublic Class Form1    'Purpose:       This project calculates the monthly payment:    '               a loan based on loan amount, interest rate(利率),    '                   Dim gdblMonths As Double = 60.0    Const MaximumLoanAllowed As Integer = 25000    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load        nudLoanAmount.Maximum = MaximumLoanAllowed    End Sub    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click        nudLoanAmount.Value = 0        nudRate.Value = 5        radFiveYears.Checked = True        txtMonthlyPayment.Text = "$0.00"    End Sub    Private Sub radTwoYears_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radTwoYears.CheckedChanged        gdblMonths = 24.0    End Sub    Private Sub radFiveYears_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radFiveYears.CheckedChanged        gdblMonths = 12.0 * 5    End Sub    Private Sub radSixYears_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radSixYears.CheckedChanged        gdblMonths = 12.0 * 6    End Sub    Private Sub btnComputePayment_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnComputePayment.Click        Dim dblRate, dblMonths, dblPayment As Double        Dim dblLoanAmount As Double, strPayment As String        dblRate = (Convert.ToDouble(nudRate.Value) / 100.0) / 12.0        dblLoanAmount = Convert.ToDouble(nudLoanAmount.Value)        dblPayment = Pmt(dblRate, gdblMonths, -dblLoanAmount)        strPayment = Format(dblPayment, "c")        'strPayment = dblPayment.ToString        ' Or use  " convert.tostring(dblPayment) "        txtMonthlyPayment.Text = strPayment        '显示的是本机的现金符号, 如需更改请用 globlization.currentinfo    End SubEnd Class

0 0
原创粉丝点击