按揭购房还款计划程序代码

  • 格式:doc
  • 大小:33.00 KB
  • 文档页数:4

这个是我们老师做的,代码是对的,但放到有写机子上无法运行
⑴按揭购房还款计划
窗体Form1的代码:
Option Explicit
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 30
cboYear1.AddItem i
Next
cboYear1.Text = 15
For i = 0 To 9
cboYear.AddItem Year(Date) + i
Next
cboYear.Text = Year(Date)
For i = 1 To 12
cboMonth.AddItem i
Next
cboMonth.Text = month(Date)
End Sub
Private Sub Command1_Click()
Dim Corpus1 As Single
Dim Corpus2 As Single
Dim Rate As Single
Dim Year As Integer
Dim i As Integer
Dim A1 As Single
Dim A2 As Single
If Val(txtCorpus.Text) = 0 Or V al(cboYear1.Text) = 0 Then MsgBox "请输入合适的贷款额。

", 48, "注意": Exit Sub
Corpus1 = txtCorpus.Text
Year = cboYear1.Text
'享受政策性贷款人数
For i = 0 To 3
If Option1(i) Then Exit For
Next
Corpus2 = i * 6 '可以进行政策性贷款的数额
'计算实际贷款额,Corpus1为商业贷款,Corpus2为政策性贷款
If Corpus1 > Corpus2 Then
Corpus1 = Corpus1 - Corpus2
Else
Corpus2 = Corpus1
Corpus1 = 0
End If
Corpus1 = Corpus1 * 10000
Corpus2 = Corpus2 * 10000
A1 = A(Corpus1, 0.05, Year)
A2 = A(Corpus2, 0.04, Year)
Load Form2 '加载Form2
Form2.Text1 = Format(A1 + A2, "0.00")
Form2.Text2 = Format((A1 + A2) * Year * 12, "0.00")
Form2.Text3 = (A1 + A2) * Year * 12 / (Corpus1 + Corpus2)
Form2.Show 1 '显示Form2
End Sub
Private Sub Command2_Click()
Dim Corpus1 As Single
Dim Corpus2 As Single
Dim Rate As Single
Dim Year As Integer
Dim i As Integer, j As Integer
Dim A1 As Single
Dim A2 As Single
Dim start_year As Integer, start_month As Integer '起始还款年月
Dim b1() As Single
Dim b2() As Single
If Val(txtCorpus.Text) = 0 Or V al(cboYear1.Text) = 0 Then MsgBox "请输入合适的贷款额。

", 48, "注意": Exit Sub
Corpus1 = txtCorpus.Text
Year = cboYear1.Text
start_year = cboYear.Text '得到起始还款年月
start_month = cboMonth.Text
ReDim b1(Year * 12)
ReDim b2(Year * 12)
'享受政策性贷款人数
For i = 0 To 3
If Option1(i) Then Exit For
Next
Corpus2 = i * 6 '可以进行政策性贷款的数额
'计算实际贷款额,Corpus1为商业贷款,Corpus2为政策性贷款
If Corpus1 > Corpus2 Then
Corpus1 = Corpus1 - Corpus2
Else
Corpus2 = Corpus1
Corpus1 = 0
End If
Corpus1 = Corpus1 * 10000
Corpus2 = Corpus2 * 10000
A1 = B(Corpus1, 0.0504, Year, b1)
A2 = B(Corpus2, 0.0405, Year, b2)
Load Form3 '加载Form3
For i = 1 To Year * 12
Form3.List1.AddItem start_year & "年" & Format(start_month, "00") & "月:" & Format(b1(i) + b2(i), "0.00") & "元"
start_month = start_month + 1
If start_month = 13 Then start_month = 1: start_year = start_year + 1 Next
Form3.Text2 = A1 + A2
Form3.Text3 = (A1 + A2) / (Corpus1 + Corpus2)
Form3.Show 1 '显示Form3
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
窗体Form2的代码
Private Sub Command1_Click()
Unload Me
End Sub
窗体Form3的代码:
Option Explicit
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command2_Click()
Dim s As String
Dim i As Integer
s = InputBox("请输入文件名及路径。

", "文件名") If s = "" Then Exit Sub
Open s For Output As 1
For i = 0 To List1.ListCount - 1
Print #1, List1.List(i)
Next
Close 1
End Sub。