Or if all the labels on your form (tab page control, user control, etc) are
using the same event handler then you could do:
' pass in your form, tab page, user control, etc as parent
Private Sub AddAllHandlers(Parent As Control)
For Each Ctrl In Parent.Controls
If TypeOf Ctrl Is Label Then
AddHandler Ctrl.Click, AddressOf GUITileProf
End If
Next Ctrl
Imran.
"CJ Taylor" <cege [ahh ttt] tavayn wooohooo hooo ohhh com> wrote in message
news:OR**************@TK2MSFTNGP10.phx.gbl...
You could run a loop through the controls for that form and if the .Name
field matches (use regex or just an instr if you wish) then do an
for each myControl in Controls
if (instr(myControl.Name, "MyLabelName_")) then
AddHandler myControl.Click, New EventHandler(AddressOf GUITileProf)
end if
next
"Confessor" <in*****@reply.to.group> wrote in message
news:Xn*********************************@130.81.64 .196... Having just figured out the function of the *sender* argument in control
events, I now have 85 labelX_Click procedures that perform the exact same
function: Call ColorChange(sender). That's it.
I could make one procedure to handle them all, of the form:
Sub GUITileProc([arguments here]) Handles Label1.Click, Label2.Click...
all the way to Label85.Click.
But that would be really messy, and if there's one thing I hate, it's
messy code. Is there any way that I could group those events together
elsewhere,
under a "group" name, then just say that GUITileProc "Handles
GUITileClicks"?
It'd make future code modification that much easier.