Solved

assign single event handler code to events of multiple control fields

Posted on 2011-03-15
3
511 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 74

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Get String split 5 33
c# if statement weird reaction 3 29
Calling stored proc in EDMX 11 19
Red error squiggly on vb.net 7 12
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now