Visual Basic 6.0 对象使用与创建全解析
1. 使用新对象
在编程中,类模块就像是对象的蓝图,Loan 类模块本身并不创建对象,而是提供一个定义,让程序根据需要创建一个或多个实际的 Loan 对象。下面是使用 Loan 对象的具体步骤:
1. 创建新项目 :启动一个新的标准 EXE 项目,只包含一个窗体。将窗体的 Caption 属性更改为“Please Click on This Form”。
2. 添加类模块 :将之前创建的 LOAN.CLS 类模块添加到项目中。
3. 添加代码到窗体 :在窗体中添加以下代码:
Option Explicit
Private Sub Form_Click()
Dim loanTest As New Loan
Dim intCount As Integer
Dim curBalance() As Currency
'Clear the face of the form
Cls
'Set loan parameters
loanTest.Reset
loanTest.Principal = 1000
loanTest.Months = 12
loanTest.AnnualInterestRate = 8.5
'Display parameters used
Print "Principal: ", , Format(loanTest.Principal, "Cur
超级会员免费看
订阅专栏 解锁全文
63

被折叠的 条评论
为什么被折叠?



