|
-
March 6th, 2000, 11:13 AM
#1
Option Button Array
I have a set of 6 option buttons. I have made them into an array (i.e. optButton(0), optButton(1), and so on. The question I have is how do I extract the number of the option button so I can tell what option has been selected? I'm sure this is easy but I can't seem to find the right syntax. I was trying to build a Case statement depending on which option button was selected. Any ideas?
-
March 6th, 2000, 01:16 PM
#2
Re: Option Button Array
you could set a trap in the click event for the option button and using the index - check the .value property to see which one was selected.
private Sub optButtons(index as Integer)
Select Case index
case 0
msgbox "First option"
case 2
msgbox "second option"
case 3
msgbox "third option"
End Select
End Sub
Of if you prefer to do it when they are about to close the form you could use something like this:
Sub GetOptions
dim i as integer
for i = 0 to ubound(optButtons)
if optButtons(i).value then
msgbox "the " & i & " option is selected"
exit for
end if
next i
End Sub
Hope this helps,
John
John Pirkey
MCSD
www.ShallowWaterSystems.com
John Pirkey
MCSD (VB6)
http://www.stlvbug.org
-
March 6th, 2000, 01:43 PM
#3
Re: Option Button Array
When I called the first code example, I had to use the .Index property instead of the Value property. So I coded:
optButtons(optDest(Index).Index)
I could never get the value property to work right. Anyway, the above call worked. Thanks for the code.
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
|