Has anyone implemented a callback mechanism in Vb 6? I have tried but have not been able to implement a solution. I have been using "Me" to send a reference to another object to invoke a reference but this fails.

I would be very grateful for any feedback on this particularly whether it can be done or not. I have some simple source below to highlight the problem. you should get

"object doesn;t support the method..........."

Don't forget to set the instancing of IState to 2 ( not creatable ), this is acting as an interface.


IState:
--------
Public Function talk() As Boolean

End Function

Public Function changeState(myContext As cls_Context) As Boolean

End Function


cls_State2
-------------
Implements IState

Private Function IState_changeState(myContext As cls_Context) As Boolean
myContext.setState (New cls_State1)
End Function

Private Function IState_talk() As Boolean

MsgBox "I'm 2"

End Function



cls_State1
-------------
Implements IState

Private Function IState_changeState(myContext As cls_Context) As Boolean
myContext.setState (New cls_State2)
End Function

Private Function IState_talk() As Boolean
MsgBox "I'm 1"
End Function



cls_Context
---------------
Private myState As IState

Public Function setState(myNewState As IState)
myState = myNewState
End Function

Public Function Speak() As Boolean
myState.talk
End Function

Private Sub Class_Initialize()
Set myState = New cls_State1
End Sub

Public Sub AlterState()
myState.changeState (Me)
End Sub

Lenin