Solved

assign single event handler code to events of multiple control fields

Posted on 2011-03-15
3
527 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 125 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 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