在分布式程序中用withevens定义对象后为何出错
编号:QA004225
建立日期: 2001年5月31日 最后修改日期:2001年5月31日
所属类别:
geyond:
操作系统:win98
编程工具:VB
问题:在分布式程序中用withevens定义对象后为何出错?
问题: 我的客户端测试程序是这样的 (testEvent.exe 在服务器端)
Option Explicit
Dim WithEvents x As testEvent.Class1
Private Sub Form_Load()
Dim l As Long
Set x = testEvent.Class1
x.test
Set x = Nothing
End Sub
Private Sub x_testEvent(Err_Module As String, err_Function As String, err_Number As Long, err_Desc As String)
MsgBox Err_Module & vbCrLf & err_Function & vbCrLf & _
"Error Number: " & err_Number & vbCrLf & _
"Error Desc: " & err_Desc & vbCrLf, vbCritical, "Error"
End Sub
但程序总是执行到Set x = testEvent.Class1时出错,有时是permission denied ,有时是
Automation Error ! 但如果我不用withEvents来定义就正常,不知何故?请各位大虾指教。。。
水平: 中级
回答:
加上一句Set x = New TestEvent.Class1
声明后必须用New关键字生成该对象的一个实例。
此问题由Yang Guang回答。
| |
|
|
| |
|
|