Archived

This topic is now archived and is closed to further replies.

md_lasalle

Events in vb6

Recommended Posts

Hey, i was wondering what is the difference between calling a Sub or an Event with vb6, what are the advantages of using events, since we must raise them,we could simply call a sub ??? thanks

Share this post


Link to post
Share on other sites
Events allow others to act in response to certain conditions that occur within your class. You raise them within the class but all other classes that care about the event only need wait for the event to be signaled. It doesn''t always make sense for these other classes to call a sub of your class.


Thanks Salsa!Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud

Share this post


Link to post
Share on other sites
Declare the instances of the class as:

WithEvents c as SomeClass

Then, you can write the event handlers to the class in which the event-exposing class is instantiated. The drop-down menu will help with this

"Events" are just syntax candy, really they are just callback pointers; VB just hides this fact well.

-Nik

Share this post


Link to post
Share on other sites