home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / ch_code / ch02 / loancalc.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-02-20  |  5.6 KB  |  181 lines

  1. VERSION 5.00
  2. Begin VB.Form LoanCalc 
  3.    Caption         =   "Loan Calculator"
  4.    ClientHeight    =   2310
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   5550
  8.    LinkTopic       =   "Form3"
  9.    ScaleHeight     =   2310
  10.    ScaleWidth      =   5550
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CheckBox PayEarly 
  13.       Alignment       =   1  'Right Justify
  14.       Caption         =   "Check if early payments"
  15.       BeginProperty Font 
  16.          Name            =   "MS Sans Serif"
  17.          Size            =   9.75
  18.          Charset         =   0
  19.          Weight          =   400
  20.          Underline       =   0   'False
  21.          Italic          =   0   'False
  22.          Strikethrough   =   0   'False
  23.       EndProperty
  24.       Height          =   240
  25.       Left            =   150
  26.       TabIndex        =   4
  27.       Top             =   1680
  28.       Width           =   2550
  29.    End
  30.    Begin VB.TextBox Duration 
  31.       BeginProperty Font 
  32.          Name            =   "MS Sans Serif"
  33.          Size            =   9.75
  34.          Charset         =   0
  35.          Weight          =   400
  36.          Underline       =   0   'False
  37.          Italic          =   0   'False
  38.          Strikethrough   =   0   'False
  39.       EndProperty
  40.       Height          =   360
  41.       Left            =   2505
  42.       TabIndex        =   3
  43.       Text            =   "48"
  44.       Top             =   1180
  45.       Width           =   1035
  46.    End
  47.    Begin VB.TextBox IRate 
  48.       BeginProperty Font 
  49.          Name            =   "MS Sans Serif"
  50.          Size            =   9.75
  51.          Charset         =   0
  52.          Weight          =   400
  53.          Underline       =   0   'False
  54.          Italic          =   0   'False
  55.          Strikethrough   =   0   'False
  56.       EndProperty
  57.       Height          =   360
  58.       Left            =   2505
  59.       TabIndex        =   2
  60.       Text            =   "14.5"
  61.       Top             =   665
  62.       Width           =   1035
  63.    End
  64.    Begin VB.TextBox Amount 
  65.       BeginProperty Font 
  66.          Name            =   "MS Sans Serif"
  67.          Size            =   9.75
  68.          Charset         =   0
  69.          Weight          =   400
  70.          Underline       =   0   'False
  71.          Italic          =   0   'False
  72.          Strikethrough   =   0   'False
  73.       EndProperty
  74.       Height          =   285
  75.       Left            =   2490
  76.       TabIndex        =   1
  77.       Text            =   "25000"
  78.       Top             =   225
  79.       Width           =   1035
  80.    End
  81.    Begin VB.CommandButton ShowPayment 
  82.       Caption         =   "Show Payment"
  83.       BeginProperty Font 
  84.          Name            =   "MS Sans Serif"
  85.          Size            =   9.75
  86.          Charset         =   0
  87.          Weight          =   400
  88.          Underline       =   0   'False
  89.          Italic          =   0   'False
  90.          Strikethrough   =   0   'False
  91.       EndProperty
  92.       Height          =   480
  93.       Left            =   3720
  94.       TabIndex        =   0
  95.       Top             =   1680
  96.       Width           =   1680
  97.    End
  98.    Begin VB.Label Label3 
  99.       Caption         =   "Duration (in months)"
  100.       BeginProperty Font 
  101.          Name            =   "MS Sans Serif"
  102.          Size            =   9.75
  103.          Charset         =   0
  104.          Weight          =   400
  105.          Underline       =   0   'False
  106.          Italic          =   0   'False
  107.          Strikethrough   =   0   'False
  108.       EndProperty
  109.       Height          =   210
  110.       Left            =   150
  111.       TabIndex        =   7
  112.       Top             =   1200
  113.       Width           =   1980
  114.    End
  115.    Begin VB.Label Label2 
  116.       Caption         =   "Interest Rate"
  117.       BeginProperty Font 
  118.          Name            =   "MS Sans Serif"
  119.          Size            =   9.75
  120.          Charset         =   0
  121.          Weight          =   400
  122.          Underline       =   0   'False
  123.          Italic          =   0   'False
  124.          Strikethrough   =   0   'False
  125.       EndProperty
  126.       Height          =   255
  127.       Left            =   150
  128.       TabIndex        =   6
  129.       Top             =   720
  130.       Width           =   1650
  131.    End
  132.    Begin VB.Label Label1 
  133.       Caption         =   "Loan's amount"
  134.       BeginProperty Font 
  135.          Name            =   "MS Sans Serif"
  136.          Size            =   9.75
  137.          Charset         =   0
  138.          Weight          =   400
  139.          Underline       =   0   'False
  140.          Italic          =   0   'False
  141.          Strikethrough   =   0   'False
  142.       EndProperty
  143.       Height          =   255
  144.       Left            =   150
  145.       TabIndex        =   5
  146.       Top             =   255
  147.       Width           =   1800
  148.    End
  149. Attribute VB_Name = "LoanCalc"
  150. Attribute VB_GlobalNameSpace = False
  151. Attribute VB_Creatable = False
  152. Attribute VB_PredeclaredId = True
  153. Attribute VB_Exposed = False
  154. Option Explicit
  155. Private Sub ShowPayment_Click()
  156. Dim Payment As Single
  157. Dim LoanIRate As Single
  158. Dim LoanDuration As Integer
  159. Dim LoanAmount As Integer
  160.     If IsNumeric(Amount.Text) Then
  161.         LoanAmount = Amount.Text
  162.     Else
  163.         MsgBox "Please enter a valid amount"
  164.         Exit Sub
  165.     End If
  166.     If IsNumeric(IRate.Text) Then
  167.         LoanIRate = 0.01 * IRate.Text / 12
  168.     Else
  169.         MsgBox "Invalid interest rate, please re-enter"
  170.         Exit Sub
  171.     End If
  172.     If IsNumeric(Duration.Text) Then
  173.         LoanDuration = Duration.Text
  174.     Else
  175.         MsgBox "Please specify the loan's duration as a number of months"
  176.         Exit Sub
  177.     End If
  178.     Payment = Pmt(LoanIRate, LoanDuration, -LoanAmount, 0, PayEarly.Value)
  179.     MsgBox Format$(Payment, "#.00")
  180. End Sub
  181.