为什么没有触发事件
这是一个ACTIVEX EXE程序
'下面是一个类ZP
'事件
Public Event NewInformation(ByVal Information As String)
'获得网络适配器信息的方法
Public Function AdapterInfor(ByVal Reserve As String) As String
mvarLastError = ""
AdapterInfor = ""
Dim strBuff As String
Dim oClass As Object
Set oClass = CreateObject("QNCOWSC1.Communication")
strBuff = ""
If oClass.EnumAdapter(1, "") = True Then
Do
strBuff = strBuff & "网络适配器名称:" & oClass.AdapterName & vbCrLf
strBuff = strBuff & "网络适配器类型:" & oClass.AdapterType & vbCrLf
strBuff = strBuff & "网络适配器IP:" & oClass.AdapterIPAddress & vbCrLf
strBuff = strBuff & "网络适配器MAC:" & oClass.AdapterPhyAddress & vbCrLf
strBuff = strBuff & "网络适配器描述:" & oClass.AdapterDescription & vbCrLf & vbCrLf
'这里应该将枚举到的信息用事件触发的方式及时通知客户程序,
'但它好象没有工作
RaiseEvent NewInformation(strBuff)
Loop While oClass.EnumAdapter(0, "")
Else
mvarLastError = oClass.LastError
End If
AdapterInfor = strBuff
Set oClass = Nothing
End Function
'客户程序
Private WithEvents zpNewInformation As ZP
Private Sub Form_Load()
Set zpNewInformation = New ZP
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set zpNewInformation = Nothing
End Sub
Private Sub ZP_ADAPTERINFOR_Click()
Dim oClass As New ZP
If oClass.AdapterInfor("") = "" Then
Text1.Text = oClass.LastError
End If
Set oClass = Nothing
End Sub
Private Sub zpNewInformation_NewInformation(ByVal Information As String)
Text1.Text = Information
End Sub
'谁能告诉我错误在哪里,使用事件还需要别的设置吗.