I have a program which has several class' sharing an implemented interface.
I would like this reference to the implemented interface to be able to
recieve an event.
My interface definition for what I call "DynCalc" looks like this:
*************************************************start code sample
' Generalized Calculation with stubbed out procedures
' for the real calculation classes to use as a implements.
Public Event Change(CalcChange As DynCalc)
Public Sub Calculate()
' Run the special code to do the calculation then call all the dependent
calculation in the
' mRegisteredCalcs collection.
End Sub
*************************************************end code sample
My definition of a class named "EventCalc" with an implemented class looks
like this
*************************************************start code sample
Option Explicit
Implements DynCalc
Public Event Change(CalcChange As DynCalc)
Private Sub DynCalc_Calculate()
'some code here
RaiseEvent Change(Me)
' some other code
End sub
*************************************************end code sample
My code currently returns an error when setting a reference to the EventCalc
class with a variable dim'd withevents.
******************error
Dim withEvents XYZ as DynCalc
Set XYZ = GetCalc("IndentifyingString") 'runtime error here
? err.Description
Object or class does not support the set of events
? Err.Number
459
******************end error
Which makes sense to me since the code has noway to know if the change event
is
defined to be part of the class or the implemented interface. Question?
Does an
interface have the event as part of it or is an event only part of a class?
Defining the event in the class with the following syntax returns an syntax
error
Public Event DynCalc_Change(CalcChange As DynCalc)
Error is you can't have an underscore in an event declaration
Can somebody help me understand how or if this can be done?
Thanks for all your help in advance
John
Archived from group: microsoft>public>vb>com