Wrox Programmer Forums
|
BOOK: Visual Basic 2005 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2005 Programmer's Reference by Rod Stephens; ISBN: 9780764571985
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2005 Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 23rd, 2007, 07:59 AM
Authorized User
 
Join Date: Dec 2006
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default Catching events

I have three classes - class A, Class B and Class C
An instance of class A creates several instances of Class B, and each of these in turn creates several instances of Class C.

An instance of Class C raises an event that I want to handle in the Class A instance.

Can you suggest a good way to do this?

Cheers

Phil

 
Old February 23rd, 2007, 10:19 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Probably the most straightforward method would be to make B declare a similar event. When B catches the C's event, it raises its own event for A to catch.

Another option would be to declare an event handler in A and then have B use the AddHandler statement to make A's event handler directly catch the C events. This would mean B needs a reference to its A object so it can refer to that event handler. It's also more confusing so I'd stick with the first option if possible; it's a lot simpler.


Rod
RodStephens@vb-helper.com
Author of "Visual Basic 2005 Programmer's Reference"
http://www.vb-helper.com/vb_prog_ref.htm

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
Catching a SQLException error digriz60 ASP.NET 1.0 and 1.1 Basics 5 January 14th, 2008 03:14 PM
Catching Up John Kauffman BOOK: Beginning ASP.NET 2.0 and Databases 2 October 2nd, 2006 05:04 PM
catching error darkhalf Javascript 4 December 14th, 2005 01:44 PM
catching the OnSelectedIndexChanged event Aaron Edwards Classic ASP Professional 1 October 5th, 2005 02:51 PM
catching error fyeojo VS.NET 2002/2003 4 August 13th, 2003 08:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.