Spiel79 Posted March 5, 2004 Posted March 5, 2004 Hello everyone. I have a form which has about ten radio buttons. When the user doesnt make any selection, how do I catch this in code? I am presently doing the following since its only ten radio buttons, but what happens if I have a 100?! How do I loop all the radiobuttons checked status? Thanks. If Me.RadioButton1.Checked = False And Me.RadioButon2.Checked = False And '.... continues for ALL the buttons Then MsgBox("Please make a selection") End If Quote
georgepatotk Posted March 5, 2004 Posted March 5, 2004 I am not sure about vb.net, I used to do this in vb6. I assign radiobuttons (checkboxes more suitable) with array. so, to check the value, i just use a loop to check one by one Quote George C.K. Low
kas Posted March 5, 2004 Posted March 5, 2004 That's VB6-Think. In VB.Net, much better to use logic like: Dim ctrl As Control For Each ctrl In Me.Controls If TypeOf ctrl Is RadioButton Then ' Action here Next Quote
techmanbd Posted March 5, 2004 Posted March 5, 2004 also if you DO use the way you have you don't need to put false. Just FYI so when you do other boolean style if statements for false if NOT me.radiobutton1.checked then end if for true if me.radiobutton1.checked then end if Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.