Hi everyone

I am new to the world of VB
Actually I wanted to know if anyone knows that how to validate option button
For example I create 3-4 option button(radio) and would like to check if the user has clicked on any of the button and then it should proceed further to the next form

Pls help me out!!

Thanks

make an array of option buttons by copying / pasting to a form, you will be asked if you want to make a control array, say yes! then when the time comes to check, just use a loop to go through the array and see which one is true! :)

You name the radio buttons all the same thing... That creates a control Array...
then you could do something like this:

for I = 0 to optionbuttonname.count - 1
     if optionbuttonname(I).value = true then
          msgbox "option: " & I & " Is Selected!"
     end if
next I

Hope that helps a little.

Hi!

At first follow this steps:
1. Create a new Form as Form1.
2. Add two Option control on the form called Option1 and Option2.
3. Add a Command button called Command1
4. Add two forms called Form2 and Form3 from Project->Add Form.

It 'll look like this:

|-------------------------------------|
|Form 1 |
|-------------------------------------|
| |
|o Option1 |
| |
|o Option2 |
| |
| ___________ |
| | Command1 | |
| ------------ |
| |
|-------------------------------------|

5. Make a double click on the Command1 button
6. Inside there write the following:

If Option1.Value = True Then
//this first If shows you Form2
Form2.Show
ElseIf Option2.Value = True Then
//this second If shows you Form3
Form3.Show
End If

And that's all.

P.D. I sent you a picture "Project.jpg" which is the form.

Andrés Rodríguez
andresfabrizio@starmedia.com

Ummm .... wouldn't it be much easier to have a Click event for each radio button so that if any button is clicked, then the next step is taken.

For example, you initialise the "OK" button to disabled. For each click event, you set the OK button to enabled.

And rather than the naming of the buttons themselves, I would assign each button a GroupName so that you can refer to the group more easily.

Alternatively, if button 1 clicked sends you down a particular path different from the path taken if the user clicks on button 2, then just use the Click even of each button to initiate the needed function.

Seems easier to me, anyway.

Regards,


Gravey

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.