Solved

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

Posted on 2003-11-20
3
193 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 50 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Protecting vb6 & .Net code Obfuscation 18 183
Can we place a tooltip on the actual vb6 form 5 51
Advice in Xamarin 21 109
VBA Replace Function - What am I missing? 3 21
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

749 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