Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2003-11-20
3
Medium Priority
?
197 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 D
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

636 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