Results 1 to 4 of 4

Thread: Which radio button is checked?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354

    Which radio button is checked?

    I am submitting some data to the database. For the most part it is all text box entry. However I have one field that requires the user to select one of three locations.

    I thought the easiest way to do this would be to create an option group with all three entries and then just grab the value of the Option Group at the time of submission.

    I have since found out that it is not that easy, unless I am missing something obvious. I have done a search on this forum but was more confused afterwards.

    I have an option group named gbLocationSelection with three choices:

    Control Name - radGR : Text - (Grand Rapds)
    Control Name - radKZ : Text - (Kamalamzoo)
    Control Name - radTC : Text - (Traverse City)

    I just want to get the text name to a string so I can put it in the database. Any ideas?

  2. #2
    Addicted Member Hole-In-One's Avatar
    Join Date
    Mar 2003
    Location
    Minnesota
    Posts
    195
    Can't you just use "Select Case"

    Then just associate the string with the appropriate case

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    try this method . It's more easier and shorter than Select Case and resuable too .

    VB Code:
    1. Private Sub ChkRbState()      
    2.         Dim c As New Control
    3.         For Each c In Me.Controls
    4.             If TypeOf c Is RadioButton Then
    5.                 If DirectCast(c, RadioButton).Checked = True Then
    6.                     MessageBox.Show(c.Text())                
    7.                 End If
    8.             End If
    9.         Next
    10.     End Sub

  4. #4
    Addicted Member Hole-In-One's Avatar
    Join Date
    Mar 2003
    Location
    Minnesota
    Posts
    195
    Nice!!

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