⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compound.frm

📁 Visual Basic 6 大学教程的代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmCompound 
   Caption         =   "Fig. 5.5: Compound Interest"
   ClientHeight    =   4605
   ClientLeft      =   2580
   ClientTop       =   1290
   ClientWidth     =   4125
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   8.25
      Charset         =   0
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H80000008&
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   4605
   ScaleWidth      =   4125
   Begin VB.ListBox lstDisplay 
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Courier"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2100
      Left            =   225
      TabIndex        =   6
      Top             =   1440
      Width           =   3675
   End
   Begin VB.CommandButton cmdExit 
      BackColor       =   &H80000005&
      Caption         =   "Exit"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   2565
      TabIndex        =   5
      Top             =   3720
      Width           =   1335
   End
   Begin VB.CommandButton cmdCalculate 
      BackColor       =   &H80000005&
      Caption         =   "Calculate"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   240
      TabIndex        =   4
      Top             =   3720
      Width           =   1695
   End
   Begin VB.TextBox txtAmount 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   2565
      TabIndex        =   1
      Top             =   810
      Width           =   1290
   End
   Begin VB.TextBox txtInterest 
      Alignment       =   2  'Center
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   3000
      MaxLength       =   2
      TabIndex        =   0
      Text            =   "5"
      Top             =   210
      Width           =   852
   End
   Begin VB.Label lblAmount 
      Caption         =   "Enter Principal:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   240
      TabIndex        =   3
      Top             =   840
      Width           =   2235
   End
   Begin VB.Label lblInterest 
      Caption         =   "Interest Rate (%):"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   240
      TabIndex        =   2
      Top             =   240
      Width           =   2385
   End
End
Attribute VB_Name = "frmCompound"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 5.5
' Calculating compound interest.
Option Explicit           ' General Declaration

Private Sub cmdCalculate_Click()
   Dim years As Integer
   Dim interestRate As Double
   Dim amount As Currency
   Dim principal As Currency
   
   lstDisplay.Clear       ' Clear list box
   years = 10             ' Initialize variable

   ' Get information from text boxes
   principal = txtAmount.Text
   interestRate = txtInterest.Text / 100

   ' Display header in list box
   lstDisplay.AddItem "Year" & vbTab & "Amount On Deposit"
   
   For years = 1 To 10
      amount = principal * (1 + interestRate) ^ years
      lstDisplay.AddItem Format$(years, "@@@@") & vbTab & _
                         Format$(Format$(amount, "Currency"), _
                         String$(17, "@"))
   Next years

End Sub

Private Sub cmdExit_Click()
   End
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -