?
Solved

Newbie question:  How to group events all to do the same thing

Posted on 2003-11-20
3
Medium Priority
?
196 Views
Last Modified: 2010-05-01
For example,

Private Sub optionButton1_MouseDown(ByVal Button As Integer, ...)
    myFunction1()
End Sub

Private Sub optionButton2_MouseDown(ByVal Button As Integer, ...)
    myFunction1()
End Sub

Private Sub optionButton3_MouseDown(ByVal Button As Integer, ...)
    myFunction1()
End Sub

1)  Is there a more efficient way of handling this for option buttons or other objects?  That is, Run myFunction1() when Event A, B, C... are found?

2)  If the answer to 1) is No, is there a more efficient way of handling this if the option buttons are using a group name or are contained within a frame?
0
Comment
Question by:wonda04
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 200 total points
ID: 9789712
make a control array (ie. name the option buttons all the same thing:

Private Sub optionButton_MouseDown(index as integer, ByVal Button As Integer...)
   msgbox "Option " & index & " clicked"
   myFunction1
end sub
0
 
LVL 8

Expert Comment

by:Rog
ID: 9789735
When you name each control the same name it is like an array.

The even shown above will fire when any control in that array is fired.  The index of which control was clicked is then passed into the function.

This can be very useful in dynamically creating controls on a form for instance.

Rog
0
 

Author Comment

by:wonda04
ID: 9789992
Hi bobbit32, Rog,

The index argument is not available with VBA. That is,...
 
    Private Sub optionButton1_MouseDown(ByVal Button As Integer, ...)

Any ideas?
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

777 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