Automobile Loan Calculator - in vb.net

'学习心得

'运算符的优先级

'变量名的制定: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 On

Public 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 Sub

End Class


  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值