Array of controls

Hai,

I want to create array of controls for ex radiobuttons and panel controls at runtime. There should be 2 or more radio button on each panel controls.
Then if check any one radio button on all panel controls and finally i have to click the submit button to get the all checked radiobuttons text in the msgbox.

How can i do this?

I am new to programming.

Comments

  • seancampbellseancampbell Pennsylvania, USA
    Wa? Explain that again?

    You want to create 3 or so sets of the same radio buttons, when you click a radio button on one set, it sets it in all of them? Then if you click submit it tells you if they are all checked or not?

    : Hai,
    :
    : I want to create array of controls for ex radiobuttons and panel
    : controls at runtime. There should be 2 or more radio button on each
    : panel controls.
    : Then if check any one radio button on all panel controls and finally
    : i have to click the submit button to get the all checked
    : radiobuttons text in the msgbox.
    :
    : How can i do this?
    :
    : I am new to programming.
    :
  • Hai
    "[color=Green]You want to create 3 or so sets of the same radio buttons, when you
    click a radio button on one set[/color]." upto this the logic is correct.

    after this, I am going to check only one radiobutton in each and every set.
    Then if click submit, it should give the text of checked radiobutton of all sets separately.


    : Wa? Explain that again?
    :
    : You want to create 3 or so sets of the same radio buttons, when you
    : click a radio button on one set, it sets it in all of them? Then if
    : you click submit it tells you if they are all checked or not?
    :
    : : Hai,
    : :
    : : I want to create array of controls for ex radiobuttons and panel
    : : controls at runtime. There should be 2 or more radio button on each
    : : panel controls.
    : : Then if check any one radio button on all panel controls and finally
    : : i have to click the submit button to get the all checked
    : : radiobuttons text in the msgbox.
    : :
    : : How can i do this?
    : :
    : : I am new to programming.
    : :
    :

    G.Manivannan, M.Sc.,[IT],
    VBA Programmer,
    AKUVA Infotech, Bangalore.
  • seancampbellseancampbell Pennsylvania, USA
    On the submit buttons try this code
    [code]
    Dim Ctl As Control
    Dim rBtn As RadioButton
    For Each Ctl In Me.Controls
    Try
    For Each rBtn In Ctl.Controls
    If rBtn.Checked = True Then
    MsgBox(rBtn.Text & " is checked.", MsgBoxStyle.SystemModal & MsgBoxStyle.OKOnly)
    End If
    Next
    Catch ex As Exception
    'ctl was not a panel
    End Try
    Next
    [/code]

    Basically what this code does is Iterates through each Control on Me (the form) and then "Trys" to iterate through the controls contained by Ctl. If Ctl is not a panel it will through an Error so I put it in a Try Catch to have it skip whenever it hits a non-panel. The nested loop iterates through each Radio button in each panel and does a MsgBox when it's checked.

    Should work for any number of panel and Radio buttons.
  • Hai,
    The code is working fine. Thanks a lot.


    G.Manivannan, M.Sc.,[it],
    VBA Programmer,
    AKUVA Infotech, Bangalore.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories