[dba-VB] Option Group and Select Case Statement

Gary Ray gray at utah.gov
Mon Sep 26 08:49:12 CDT 2005


The first assumption here is that you have a control array of option buttons - in other words, give the set of buttons the same name.  Then this code should work:

    Select Case True
        Case optName(0).Value
            MsgBox optName(0).Caption
        Case optName(1).Value
            MsgBox optName(1).Caption
        Case optName(2).Value
            MsgBox optName(2).Caption
        Case Else
            MsgBox "Not Selected"
    End Select

Gary Ray - Application Developer
Workforce Information Systems R & D
E-Mail gray at utah.gov

>>> RRANTHON at sentara.com 9/26/2005 6:33 AM >>>
Hi peeps, dumb question of the day.

In Access, I can create an option group, then use a select case
optiongroupname and run appropriate code within the case statement.  How
do I do this in VB?

I've created a frame, within the frame I've put 3 option buttons.
Here's the code:

Private Sub cmdPrint()
   
   Select Case optButtons
        Case 1 
          msgbox "bob"
        Case 2
          msgbox "fred"
        Case 3
          msgbox "Al"
    End Select

I receive an Argument not Optional error on the select Case statement. 
Your help is appreciated.
_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com 
http://databaseadvisors.com/mailman/listinfo/dba-vb 
http://www.databaseadvisors.com 





More information about the dba-VB mailing list