VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "买房贷款"
   ClientHeight    =   3195
   ClientLeft      =   -210
   ClientTop       =   630
   ClientWidth     =   5040
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   5040
   Begin VB.CommandButton 命令显示 
      Caption         =   "显示房型平面图"
      Height          =   855
      Left            =   3840
      TabIndex        =   16
      Top             =   2040
      Width           =   975
   End
   Begin VB.TextBox 文本按揭 
      Height          =   495
      Left            =   1080
      TabIndex        =   9
      Top             =   2520
      Width           =   615
   End
   Begin VB.TextBox 文本首付 
      Height          =   495
      Left            =   120
      TabIndex        =   7
      Top             =   2520
      Width           =   615
   End
   Begin VB.ListBox 列表单价 
      Height          =   780
      Left            =   2520
      TabIndex        =   3
      Top             =   600
      Width           =   735
   End
   Begin VB.ListBox 列表房型 
      Height          =   780
      Left            =   120
      TabIndex        =   0
      Top             =   600
      Width           =   1215
   End
   Begin VB.Label 标签显示月付 
      BorderStyle     =   1  'Fixed Single
      Height          =   495
      Left            =   2880
      TabIndex        =   15
      Top             =   2520
      Width           =   735
   End
   Begin VB.Label 标签月付 
      Caption         =   "月付元"
      Height          =   375
      Left            =   3000
      TabIndex        =   14
      Top             =   2040
      Width           =   615
   End
   Begin VB.Label 标签显示面积 
      Alignment       =   2  'Center
      BorderStyle     =   1  'Fixed Single
      Height          =   495
      Left            =   1440
      TabIndex        =   13
      Top             =   720
      Width           =   855
   End
   Begin VB.Label 标签面积 
      Caption         =   "面积"
      Height          =   495
      Left            =   1440
      TabIndex        =   12
      Top             =   240
      Width           =   735
   End
   Begin VB.Label 标签显示年利率 
      BorderStyle     =   1  'Fixed Single
      Height          =   495
      Left            =   1920
      TabIndex        =   11
      Top             =   2520
      Width           =   735
   End
   Begin VB.Label 标签年利率 
      Caption         =   "年利率%"
      Height          =   375
      Left            =   2040
      TabIndex        =   10
      Top             =   2040
      Width           =   615
   End
   Begin VB.Label 标签按揭 
      Caption         =   "按揭/年"
      Height          =   375
      Left            =   1200
      TabIndex        =   8
      Top             =   2040
      Width           =   495
   End
   Begin VB.Label 标签首付 
      Caption         =   "首付/万元"
      Height          =   255
      Left            =   120
      TabIndex        =   6
      Top             =   2040
      Width           =   855
   End
   Begin VB.Label 标签显示总价 
      BorderStyle     =   1  'Fixed Single
      Height          =   495
      Left            =   3480
      TabIndex        =   5
      Top             =   720
      Width           =   1095
   End
   Begin VB.Label 标签总价 
      Caption         =   "总价"
      Height          =   375
      Left            =   3720
      TabIndex        =   4
      Top             =   240
      Width           =   735
   End
   Begin VB.Label 标签单价 
      Caption         =   "单价 元/m2"
      Height          =   375
      Left            =   2640
      TabIndex        =   2
      Top             =   120
      Width           =   615
   End
   Begin VB.Label 标签房型 
      Caption         =   "房型"
      Height          =   375
      Left            =   240
      TabIndex        =   1
      Top             =   240
      Width           =   735
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim 面积(3) As Integer, indexi As Integer

Private Sub 命令显示_Click()
   Select Case indexi        '根据房型，在另一窗体显示平面图
      Case 0
        Form2.Picture1 = LoadPicture(App.Path + "\3_1.wmf")
      Case 1
        Form2.Picture1 = LoadPicture(App.Path + "\2_1.wmf")
      Case 2
        Form2.Picture1 = LoadPicture(App.Path + "\1_1.wmf")
    End Select
    Form2.Caption = Form1.列表房型
  Form2.Show
End Sub

Private Sub Form_Load()
   列表房型.AddItem "三房一厅"   '假设三种房型
   列表房型.AddItem "二房一厅"
   列表房型.AddItem "一房一厅"
                        '根据三种房型，假设每种房型面积
   面积(0) = 130: 面积(1) = 100: 面积(2) = 80
   列表单价.AddItem "2500"       '假设每平方米加入单价列表框
   列表单价.AddItem "3500"
   列表单价.AddItem "4500"
   列表单价.AddItem "5500"
   
End Sub

Private Sub 列表单价_Click()
   标签显示总价.Caption = Val(面积(indexi)) * Val(列表单价)
End Sub

Private Sub 列表房型_Click()
   indexi = 列表房型.ListIndex     '根据选择的房型，显示该房型的面积
   标签显示面积.Caption = 面积(indexi)
End Sub

Private Sub 文本按揭_Change()
      ' 根据贷款额，按揭年数，年利率，调用Pmt函数，计算每月支付额
   Dim rate As Single, nper As Integer, pv As Single
   rate = Val(文本按揭) / 12 / 100
   nper = Val(文本按揭) * 12
   pv = Val(标签显示总价) - Val(文本首付) * 10000
   标签显示年利率 = 文本按揭
   标签显示月付 = Format(Pmt(rate, nper, -pv), "0.00")
End Sub

