CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2005

    determine which option (radio) button is active

    Here is a function I made up (with tips from Hannesthegreat and Wof)..might come in handy....
    'Determines & returns which option button in an array is presently active
    'Returns -1 when none are active (such as at initialization)
    'example:  text3.text=str(WhichOptionActive(optRadioButtonBank1))
    Public Function WhichOptActive(CtrlArr As Variant) As Integer
    Dim Cntrl As Control
    WhichOptActive = -1  'default, if none active
    For Each Cntrl In CtrlArr
      If Cntrl.Value = True Then       'look for active option button
       WhichOptActive = Cntrl.Index
       Exit Function  'if found, get out now
      End If
    Next Cntrl
    End Function
    Last edited by WizBang; May 7th, 2009 at 07:58 AM. Reason: Added [code] tags

  2. #2
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: determine which option (radio) button is active

    None of us EVER post code without using CODE TAGS!!!
    ' Please learn how to use them, or don't post any more code.
    That didn't really help anyone, so who will search for it? Add it to your other post instead

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Tags for this Thread

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.