Hi all,
I've created a class the defines an Event. This event is raised when a configuration file cannot be found.
I've declared in the main sdi form:
Dim WithEvents m_Config as Config
In the Class's Initialize event I check to see if this file exists. If it doesn't I raise the event.
Private Sub Class_Initialize()
Set fsO = CreateObject("Scripting.FileSystemObject")
If (Not fsO.FileExists("test.cfg")) Then
RaiseEvent CfgIOError("Config file is Missing!")
Else
' Todo read configuration
End If
End Sub
Back in the Main SDI form I've added:
Private Sub m_Config_CfgIOError(m_Error As String)
m_Status.Panels(1).Text = m_Error
End Sub
If I use a breakpoint I can see that this event is being fired but it is never intercepted in the main form! The class in question is being created in the form's Load event:
Set m_Config = New Config
Can anyone tell me where I'm going or what I'm doing wrong, please. This is driving me crazy! I guess it may well be something trivial but I can't see it. According to the MSDN topic "Adding Events to a Class", I'm on the right track.
--
Thanks,
William.
I've created a class the defines an Event. This event is raised when a configuration file cannot be found.
I've declared in the main sdi form:
Dim WithEvents m_Config as Config
In the Class's Initialize event I check to see if this file exists. If it doesn't I raise the event.
Private Sub Class_Initialize()
Set fsO = CreateObject("Scripting.FileSystemObject")
If (Not fsO.FileExists("test.cfg")) Then
RaiseEvent CfgIOError("Config file is Missing!")
Else
' Todo read configuration
End If
End Sub
Back in the Main SDI form I've added:
Private Sub m_Config_CfgIOError(m_Error As String)
m_Status.Panels(1).Text = m_Error
End Sub
If I use a breakpoint I can see that this event is being fired but it is never intercepted in the main form! The class in question is being created in the form's Load event:
Set m_Config = New Config
Can anyone tell me where I'm going or what I'm doing wrong, please. This is driving me crazy! I guess it may well be something trivial but I can't see it. According to the MSDN topic "Adding Events to a Class", I'm on the right track.
--
Thanks,
William.