+ Reply to Thread
Results 1 to 2 of 2

Option Groups and Select Case

Hybrid View

  1. #1
    Nubby
    Guest

    Option Groups and Select Case

    Greetings,
    I'm currently setting up a script that will select an array based on
    specific criteria. I'm using the select case method. The problem is that I
    want the user to select a radio button and the value of that radio button
    will determine the array to use.

    I have the 5 options buttons named optOne, optTwo, etc...
    I have one frame named fraFormat
    The option buttons are part of the group grpFormat

    At the bottom of the form I have a button that is named cmdFormat

    I have this function that will assign values to an array

    Function Selection(OpUnitFormat)

    Select Case OpUnitFormat
    Case 1
    strOpUnitProd(1) = ""
    strOpUnitProd(2) = ""
    strOpUnitProd(3) = ""
    strOpUnitProd(4) = ""
    strOpUnitProd(5) = ""

    Case 2
    strOpUnitProd(1) = ""
    strOpUnitProd(2) = ""
    strOpUnitProd(3) = ""
    strOpUnitProd(4) = ""
    strOpUnitProd(5) = ""

    Case 3
    strOpUnitProd(1) = ""
    strOpUnitProd(2) = ""
    strOpUnitProd(3) = ""
    strOpUnitProd(4) = ""
    strOpUnitProd(5) = ""

    Case 4
    strOpUnitProd(1) = ""
    strOpUnitProd(2) = ""
    strOpUnitProd(3) = ""
    strOpUnitProd(4) = ""
    strOpUnitProd(5) = ""

    Case 5
    strOpUnitProd(1) = ""
    strOpUnitProd(2) = ""
    strOpUnitProd(3) = ""
    strOpUnitProd(4) = ""
    strOpUnitProd(5) = ""

    End Select
    End Function

    *******************************
    What am I doing wrong with the following:
    *******************************

    Private Sub cmdFormat_Click()
    Call Selection(fraFormat.ActiveControl.TabIndex)

    End Sub

    Is there a better way to do this? Thanks for any help.

    --
    A rolling stone gathers no moss but leaves a trail of busted stuff.

  2. #2
    JMB
    Guest

    RE: Option Groups and Select Case

    Functions return values, objects, or other data structures. Try changing
    your function to a Sub.

    Also, I would be wary about using Selection as a procedure name as VBA has a
    Selection object - could cause confusion.

    "Nubby" wrote:

    > Greetings,
    > I'm currently setting up a script that will select an array based on
    > specific criteria. I'm using the select case method. The problem is that I
    > want the user to select a radio button and the value of that radio button
    > will determine the array to use.
    >
    > I have the 5 options buttons named optOne, optTwo, etc...
    > I have one frame named fraFormat
    > The option buttons are part of the group grpFormat
    >
    > At the bottom of the form I have a button that is named cmdFormat
    >
    > I have this function that will assign values to an array
    >
    > Function Selection(OpUnitFormat)
    >
    > Select Case OpUnitFormat
    > Case 1
    > strOpUnitProd(1) = ""
    > strOpUnitProd(2) = ""
    > strOpUnitProd(3) = ""
    > strOpUnitProd(4) = ""
    > strOpUnitProd(5) = ""
    >
    > Case 2
    > strOpUnitProd(1) = ""
    > strOpUnitProd(2) = ""
    > strOpUnitProd(3) = ""
    > strOpUnitProd(4) = ""
    > strOpUnitProd(5) = ""
    >
    > Case 3
    > strOpUnitProd(1) = ""
    > strOpUnitProd(2) = ""
    > strOpUnitProd(3) = ""
    > strOpUnitProd(4) = ""
    > strOpUnitProd(5) = ""
    >
    > Case 4
    > strOpUnitProd(1) = ""
    > strOpUnitProd(2) = ""
    > strOpUnitProd(3) = ""
    > strOpUnitProd(4) = ""
    > strOpUnitProd(5) = ""
    >
    > Case 5
    > strOpUnitProd(1) = ""
    > strOpUnitProd(2) = ""
    > strOpUnitProd(3) = ""
    > strOpUnitProd(4) = ""
    > strOpUnitProd(5) = ""
    >
    > End Select
    > End Function
    >
    > *******************************
    > What am I doing wrong with the following:
    > *******************************
    >
    > Private Sub cmdFormat_Click()
    > Call Selection(fraFormat.ActiveControl.TabIndex)
    >
    > End Sub
    >
    > Is there a better way to do this? Thanks for any help.
    >
    > --
    > A rolling stone gathers no moss but leaves a trail of busted stuff.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1