Automobile Loan Calculator - in vb.net

前端之家收集整理的这篇文章主要介绍了Automobile Loan Calculator - in vb.net前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. '学习心得
  2.  
  3. '运算符的优先级
  4.  
  5. '变量名的制定:g(是否是全局)+数据类型+变量=变量名;gdblName
  6.  
  7. ' 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.
  8.  
  9. '
  10.  
  11.  
  12.  
  13. 'MonthlyPayment = (InterestRate*(1+InterestRate)^NumberOfPayments)/((1+InterestRate)^NumberOfPayments-1)*LoanAmount 这个在 Pmt Founction 里面有
  14.  
  15. 'Format Function 将日期,时间等转换成专用的格式
  16.  
  17.  
  18.  
  19.  
  20.  
  21. Option Strict On
  22.  
  23. Public Class Form1
  24.  
  25. 'Purpose: This project calculates the monthly payment:
  26.  
  27. ' a loan based on loan amount,interest rate(利率),'
  28.  
  29.  
  30.  
  31. Dim gdblMonths As Double = 60.0
  32.  
  33. Const MaximumLoanAllowed As Integer = 25000
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41. Private Sub Form1_Load(ByVal sender As Object,ByVal e As System.EventArgs) Handles Me.Load
  42.  
  43. nudLoanAmount.Maximum = MaximumLoanAllowed
  44.  
  45. End Sub
  46.  
  47.  
  48.  
  49. Private Sub btnReset_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles btnReset.Click
  50.  
  51. nudLoanAmount.Value = 0
  52.  
  53. nudRate.Value = 5
  54.  
  55. radFiveYears.Checked = True
  56.  
  57. txtMonthlyPayment.Text = "$0.00"
  58.  
  59. End Sub
  60.  
  61.  
  62.  
  63. Private Sub radTwoYears_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles radTwoYears.CheckedChanged
  64.  
  65. gdblMonths = 24.0
  66.  
  67. End Sub
  68.  
  69.  
  70.  
  71. Private Sub radFiveYears_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles radFiveYears.CheckedChanged
  72.  
  73. gdblMonths = 12.0 * 5
  74.  
  75. End Sub
  76.  
  77.  
  78.  
  79. Private Sub radSixYears_CheckedChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles radSixYears.CheckedChanged
  80.  
  81. gdblMonths = 12.0 * 6
  82.  
  83. End Sub
  84.  
  85.  
  86.  
  87. Private Sub btnComputePayment_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles btnComputePayment.Click
  88.  
  89. Dim dblRate,dblMonths,dblPayment As Double
  90.  
  91. Dim dblLoanAmount As Double,strPayment As String
  92.  
  93. dblRate = (Convert.ToDouble(nudRate.Value) / 100.0) / 12.0
  94.  
  95. dblLoanAmount = Convert.ToDouble(nudLoanAmount.Value)
  96.  
  97. dblPayment = Pmt(dblRate,gdblMonths,-dblLoanAmount)
  98.  
  99. strPayment = Format(dblPayment,"c")
  100.  
  101. 'strPayment = dblPayment.ToString ' Or use " convert.tostring(dblPayment) "
  102.  
  103. txtMonthlyPayment.Text = strPayment '显示的是本机的现金符号, 如需更改请用 globlization.currentinfo
  104.  
  105. End Sub
  106.  
  107. End Class
  108.  

猜你在找的VB相关文章