Results 1 to 3 of 3

Thread: Resetting Option Buttons programmatically

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Location
    Houston, TX - USA
    Posts
    21

    Post

    If I have 12 option buttons in three containers at the same form (for example, 2 in frame1 and 4 in frame2 and 6 in frame 3.

    OptionButtons in containers are not an array, but have individual Names.

    The user may choose one button in each container at the same time.

    I would like to give him/her the chance to reset his choices.

    I tried something like this
    _____________

    Private Sub Command1_Click()
    Dim MyButton as OptionButton
    Dim Forms as Form

    For each MyButton in Forms
    MyButton.Value = False
    next MyButton
    End Sub_________

    1 -What is wrong with my code?
    2- Can I create a Function Reset(), which shall work only in a certain form within the application?
    3- If a function is possible, how to call it?


    Please help


    If the user chooses opt1 (in frame1) not all of the choices in frame 2 are valid. Suppose that only opt3, opt4 and opt5 are valid choices.

    I know how to change the properties programatically, yet I would like to use a For...Next statement to do it.

    Its a simple code, yet I am stuck in my attempts.

    Can anybody help, please???




    ------------------
    Paul Stermann
    DSI-Houston

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    Try this:
    Code:
    Private Sub Command1_Click()
    For Each Control In Me
       If TypeOf Control Is OptionButton Then Control.Value = False
    Next
    End Sub
    --------------------------
    Or as Function:
    (in module)

    Code:
    Public Function ResetOption (FormName)
        For Each Control in FormName
            If TypeOf Control Is OptionButton Then Control.Value = False
        Next
    End Function
    (In Command_Button)
    Code:
    Private Sub Command1_Click()
        ResetOption Form1
    End Sub

    Hope this will help
    Regards

    ------------------
    Visual Basic Programmer (at least I want to be one)
    ------------------
    PolComSoft
    You will hear a lot about it.

    [This message has been edited by QWERTY (edited 11-09-1999).]

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Location
    Houston, TX - USA
    Posts
    21

    Post

    Thank you so much QWERTY

    ------------------
    Paul Stermann
    DSI-Houston

Posting Permissions

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



Click Here to Expand Forum to Full Width