Solved

assign single event handler code to events of multiple control fields

Posted on 2011-03-15
3
518 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
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 85

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 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