Brett Barabash
BBarabash at TappeConstruction.com
Tue Sep 14 10:44:59 CDT 2004
>So this in the "reverse" of calling a sub from several events? >You specify a sub and specify - withing this - which events should call the sub? Exactly, that's what the Handles keyword is all about. Delegation is one of the new VB.NET features that opens up all sorts of possibilities. Notice the argument list for the button click handler: ByVal sender As System.Object, ByVal e As System.EventArgs These standard arguments are used for all handlers. Therefore, you could create a single handler to handle your button click and a checkbox click (and a textbox change for that matter!). The Handles keyword serves as a nice tidy wrapper around the System.Delegate assembly. There are some cool things that can be done through code, like dynamically assigning a method from one class (or control) to be automatically handled by another classes method. -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock Sent: Tuesday, September 14, 2004 9:56 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] OT: Modify the default event handlers to mimicthebehavior of VB 6 control arrays (VB .NET) Hi Brett and John Brett, thanks for clearing this up. I can see I have been victimised by unreadable code as I - as you guessed - wearing my Access goggles read Button1_Click as the event handler. So this in the "reverse" of calling a sub from several events? You specify a sub and specify - withing this - which events should call the sub? Have in mind please, that I'm not familiar with neither VB6 or dot Net. Of course you are both right about WithEvents. However, sometimes you just need to, say, have updating of a checkbox and clicking a button to do the same; then I don't write duplicate code but move it to a sub which I call from the relevant events. /gustav -------------------------------------------------------------------------------------------------------------------- The information in this email may contain confidential information that is legally privileged. The information is only for the use of the intended recipient(s) named above. If you are not the intended recipient(s), you are hereby notified that any disclosure, copying, distribution, or the taking of any action in regard to the content of this email is strictly prohibited. If transmission is incorrect, unclear, or incomplete, please notify the sender immediately. The authorized recipient(s) of this information is/are prohibited from disclosing this information to any other party and is/are required to destroy the information after its stated need has been fulfilled. Any views expressed in this message are those of the individual sender, except where the sender specifies and with authority, states them to be the views of Tappe Construction Co. This footer also confirms that this email message has been scanned for the presence of computer viruses.Scanning of this message and addition of this footer is performed by SurfControl E-mail Filter software in conjunction with virus detection software.