Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Case w/ Control array

Status
Not open for further replies.

HobbitK

Technical User
Joined
Jan 14, 2003
Messages
235
Location
US
Hi everyone ...
I know as soon as someones answers this I am going to feel foolish, but ...
I have about 25 option buttons in a control array and on a command button click, I need to capture which one has a value = true. So, I need a Select case statement to do it and I am lost on how to start it.
Thanks in advance
Michael
 

Not a select case but:

For i = 0 To Option1.Count - 1
If Option1(i).Value = True Then
' .. do something
End If
Next




Mark
 
Why not in the Click event of the option buttons place the option button index value into the Tag property of the command button. Then the case statement inside the click event is fairly straightforwad.

Select Case cmdButton.Tag
Case 1
Function1
Case 2
Function2
etc.

Or you could even place the name of the function inside the .Tag property and use the .Eval method to executed that function and never have a case statement, or cascading If-Then-Else anywhere.



Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thanks guys ...
2 methods I did not even think of !
Michael
 
And probably the easiest method is to use a private variable:

Option Explicit

Private m_iWhichButtonIsTrue As Integer

Private Sub Option1_Click(Index As Integer)
m_iWhichButtonIsTrue = Index
End Sub

Private Sub Command1_Click()
MsgBox "Option1 button with an index of: " & m_iWhichButtonIsTrue & " is True"
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top