Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / January 2006



Tip: Looking for answers? Try searching our database.

Visual Basic 6.0 function pointers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J - 29 Jan 2006 22:34 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!
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]
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.