Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

assign single event handler code to events of multiple control fields

Posted on 2011-03-15
3
Medium Priority
?
531 Views
Last Modified: 2012-06-21
I have multiple e.g. Text field controls on a Windows form (VB6).
Instead of coding always the same routine for e.g. TextChanged events of each of the fileds I like to assign those events to the same coding instance.
The "sender" System.Object parameter should allow me to handle any differences in the singlke code insatnces related to the various Text control elements.
I assume that such an approach should also be able to handle the different "e" System.EventArgs in a single coding instance.

My problem is that I don't know how to specify the individual event handlers for each of the control fielsd with assignment to the single coding instance.

I assume that this is a stupid questing of a novice to Studio 2010 / VB6 programming.
0
Comment
Question by:Phyllax
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 35144958
In VB.NET, you have 3 options:


You can assign the handler through the properties window by multi-selecting the controls you want to set the handler for, and then clicking the lightning bolt in the Properties pane; then it's a matter of simply selecting the appropriate event and its respective handler.
You can use a "Handles" clause on your event handler and list each control.event you want that handler to handle
You can use the AddHandler() function to assign a handler to an event
0
 
LVL 10

Expert Comment

by:Asim Nazir
ID: 35145065
Add a EventHandler and assign it to any control as shown below:
 Event
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 35147475
...you are NOT coding in VB6 if you have VS2010.  You would be using VB.Net then!  =)

*VB6 is a very different beast than VB.Net.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question