现在的位置: 首页 > 综合 > 正文

VB 插件的实现

2013年03月09日 ⁄ 综合 ⁄ 共 641字 ⁄ 字号 评论关闭
定义一个事件处理类,类名为 clsBill
    Public Event BeforeSave()
    Public Event AfterSave()

    Public Sub save()
        RaiseEvent BeforeSave
        Debug.Print "save过程"
        RaiseEvent AfterSave
    End Sub
编译出来的dll为 project1.dll

插件处理类1 test1
Public WithEvents m_bill As project1.clsBill

Private Sub Class_Initialize()
    Set m_bill = New clsBill
End Sub

Private Sub Class_Terminate()
    Set m_bill = Nothing
End Sub

Private Sub m_bill_BeforeSave()
    Debug.Print "引发了 BeforeSave 事件"
End Sub
编译出来的dll 为 addin1.dll ,该类名为 addin1.test1

在主窗体中,
Dim obj As Object

Dim component As String

Private Sub Command1_Click()
    obj.m_bill.save
End Sub

Private Sub Form_Load()
    component = "addin1.test1"
    Set obj = CreateObject(component)
End Sub

 

抱歉!评论已关闭.