Is it possible to pass an addressof (some function ) to a class and have
that class call the function to which the pointer points to?
Thanks alot!
Phill W. - 30 Jan 2006 12:27 GMT
> Is it possible to pass an addressof (some function ) to a class and have
> that class call the function to which the pointer points to?
Don't think so, no and it would be pretty scary if you could.
How about using an Interface that defines your "callback" method and
have the two classes work with that, as in
[ICallback.cls]
Interface ICallBack
Public Sub Beep()
End Sub
[Class1.cls]
Implements ICallBack
Public Sub ICallBack_Beep()
' Code that actually goes Beep
End Sub
[Class2.cls]
Public Sub DoBeep( ByVal beeper As ICallBack )
Call beeper.Beep()
End Sub
then
Dim c1 as Class1 : Set c1 = New Class1
Dim c2 as Class2 : Set c2 = New Class2
Call c2.DoBeep( c1 )
HTH,
Phill W.
Tom Shelton - 31 Jan 2006 05:54 GMT
> Is it possible to pass an addressof (some function ) to a class and have
> that class call the function to which the pointer points to?
>
> Thanks alot!
Well... Yes. It is possible. But, I don't recommend it. I would do
as Phil suggested, and use an interface.
If you really are interested in doing what you suggest, you can pick up
a copy of Matthew Curland's book "Advanced Visual Basic 6".
--
Tom Shelton [MVP]