我需要在类库上设置事件并以表单捕获它们。
例如,我在DLL file http://en.wikipedia.org/wiki/Dynamic-link_library,我需要“接收”类中的子程序正在运行的事件。
DLL 文件是我在 Visual Basic 中创建的,但是如何在其上引发事件以在窗体中捕获?
请举个例子。
dll中的代码
Public Event MySpecialEvent ()
Private Sub Test
RaiseEvent MySpecialEvent
End Sub
表格中的代码
Private _MyDll as MyDLL
Public Sub Main
_MyDLL = New MyDLL
AddHandler _MyDLL.MySpecialEvent, AddressOf MySpecialEventHandler
End Sub
Private Sub MySpecialEventHandler
'Put your code here to act upon the handled event
End Sub
您还需要在表单生命周期中的某个时刻删除事件处理程序
RemoveHandler _MyDLL.MySpecialEvent, AddressOf MySpecialEventHandler
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)