|
-
Sep 13th, 2009, 03:21 PM
#1
Thread Starter
New Member
[RESOLVED] How to identify the control that was clicked?
Could anyone please tell me how my program could identify the control that is clicked? In other words, lets say I have 20 controls on the form(no arrays, all different control types). And in the click event for any given control, I want to be able to call a function and pass to that function the name of the control that was clicked. How would I code that? Thanks in advance. Ron E.
-
Sep 13th, 2009, 04:31 PM
#2
Re: How to identify the control that was clicked?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 13th, 2009, 04:31 PM
#3
Re: How to identify the control that was clicked?
Welcome to the forums.
Any clickable control has a click event, pass itself to the function
Code:
Private Sub Image1_Click()
ProcessClickedControl Image1
End Sub
Private Sub ProcessClickedControl(theControl As Control)
MsgBox theControl.Name & " was just clicked"
End Sub
-
Sep 13th, 2009, 04:49 PM
#4
Thread Starter
New Member
Re: How to identify the control that was clicked?
Thanks, Keith. I just could not believe it was that simple. Ron
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|