By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,165 Members | 1,502 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,165 IT Pros & Developers. It's quick & easy.

Multiple Controls in a single Sub?

P: n/a
Take this example:

Private Sub nPnlProfile_MouseHovers(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles comboProfileName.MouseHover,
btnDelete.MouseHover, btneditFolderPath.MouseHover,
comboThumbQuality.MouseHover, comboThumbSize.MouseHover,
btnAddFile.MouseHover, ListBox1.MouseHover, btnRemove.MouseHover

'Do Something

End Sub

Is there a way to detect which control is firing so I can run code for that
control.mousehover? I figured that would be better then having a hundred
some subs.

Is this an appropriate way to code?

Thanks,
Justin
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

Sender is the control which fired the event.

If sender is listbox1 then
'do something
elseif sender is comboprofilename then
'do something else
......etc

Ken
----------------
"Justin" <Ju****@NoSpam.com> wrote in message
news:OX**************@TK2MSFTNGP15.phx.gbl...
Take this example:

Private Sub nPnlProfile_MouseHovers(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles comboProfileName.MouseHover,
btnDelete.MouseHover, btneditFolderPath.MouseHover,
comboThumbQuality.MouseHover, comboThumbSize.MouseHover,
btnAddFile.MouseHover, ListBox1.MouseHover, btnRemove.MouseHover

'Do Something

End Sub

Is there a way to detect which control is firing so I can run code for that
control.mousehover? I figured that would be better then having a hundred
some subs.

Is this an appropriate way to code?

Thanks,
Justin

Nov 21 '05 #2

P: n/a
That's exactly what I needed. Thanks Ken!

Private Sub nPnlProfile_MouseHovers(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles comboProfileName.MouseHover,
btnDelete.MouseHover, btneditFolderPath.MouseHover,
comboThumbQuality.MouseHover, comboThumbSize.MouseHover,
btnAddFile.MouseHover, btnRemove.MouseHover, listFileTypes.MouseHover
If sender Is comboProfileName Then nPnlProfile.FooterText = "Select an
existing name from the drop down list or input a new profile name then hit
ENTER"
If sender Is btnDelete Then nPnlProfile.FooterText = "Select this button to
delete the currently selected profile"
If sender Is btneditFolderPath Then nPnlProfile.FooterText = "Select the
folder path your templates"
If sender Is comboThumbQuality Then nPnlProfile.FooterText = "Select the
compression quality for your thumbnails"
If sender Is comboThumbSize Then nPnlProfile.FooterText = "Select the size
you wish your thumbnails to be"
If sender Is btnAddFile Then nPnlProfile.FooterText = "Add a file mask to
the search paramters"
If sender Is listFileTypes Then nPnlProfile.FooterText = "This area will
show you the file types the currently selected profile will search for"
If sender Is btnRemove Then nPnlProfile.FooterText = "Select a file type
then select remove to remove that file type from the list"
.........

End Sub
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:ON*************@TK2MSFTNGP15.phx.gbl...
Hi,

Sender is the control which fired the event.

If sender is listbox1 then
'do something
elseif sender is comboprofilename then
'do something else
.....etc

Ken
----------------
"Justin" <Ju****@NoSpam.com> wrote in message
news:OX**************@TK2MSFTNGP15.phx.gbl...
Take this example:

Private Sub nPnlProfile_MouseHovers(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles comboProfileName.MouseHover,
btnDelete.MouseHover, btneditFolderPath.MouseHover,
comboThumbQuality.MouseHover, comboThumbSize.MouseHover,
btnAddFile.MouseHover, ListBox1.MouseHover, btnRemove.MouseHover

'Do Something

End Sub

Is there a way to detect which control is firing so I can run code for
that
control.mousehover? I figured that would be better then having a hundred
some subs.

Is this an appropriate way to code?

Thanks,
Justin

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.