Username:
Password:
Microsoft Visual Basic 2005 Tutorials

Controls and Properties / Radio Buttons vs. Check Boxes

Subtitles of the Movie

In this movie we're going to be working with Visual Basic radio buttons and check boxes. Radio buttons are placed onto the form by selecting a radio button from the tool box. Typically you place radio buttons on a form to have the user select one of several choices presented to them. The emphasis here is to force the user to choose only one choice and not more than one. Another control, the check box, will be used when you would like to give the user the option of selecting more than one item. Check boxes will be discussed next. Since radio buttons represent choices presented to the user and these choices are to function together, it is best to first create a group box and then create each radio button inside the group box. So I will delete the radio button already placed on the form. Select it, Right click, Choose delete. You can also select the delete key on the keyboard. Now let's place a group box on the form. Find the group box control in the tool box, it is in the container section. Click it to select it and then draw the group box on the form. Think of this group box as our container for the radio buttons. Next, select the radio button control and draw it inside the group box. Be careful that you're selecting the radio button and you're drawing it inside the group box. Repeat the process for the second radio button making sure you draw the radio button inside the group box. Repeat the process once more for the third radio button. If necessary, you can now adjust your group box, if you have correctly placed the radio buttons inside the group box you should be able to move the entire group box and all contents will move along with it. If on the other hand you move the group box and one of the objects does not follow then that object is not truly a part of the group box. This will cause other problems later on. Now let's place some check boxes on the form so we can compare these two controls. In the same way as for the radio buttons first draw a group box and then draw check boxes inside the group box. Select the check box and draw it inside the group box. I'll draw four check boxes inside this group box. If this were a complete application, we would next rename each radio button and check box but for this demonstration we will leave the default names of Radio Button 1, Radio Button 2, Radio Button 3, and Check Box 1, 2, 3, and 4. Now let's understand how these controls will behave even before we write any code for them. As I execute the application, you will note that the user is able to select only one radio button within the group. As the user selects the various radio buttons, only one at a time will be selected with radio buttons. As I select another radio button, the previously selected button is automatically deselected but with check boxes, their behavior is different. The user may select as many check boxes as they wish in any combination. And checking one does not have an effect on the other. Note that no code is occurring at this point and these are the inherent properties of radio buttons and check boxes. This demonstrates the fundamental difference between radio buttons and check boxes. Later we will see how these controls can be used to interact with code to implement a complete application.

Tutorial Information

Course: Microsoft Visual Basic 2005
Author: Arthur Lee
SKU: 33940
ISBN: 1-935320-10-6
Release Date: 2008-11-19
Duration: 7.5 hrs / 97 lessons
Work Files: Yes
Captions: Available on CD and Online University
Compatibility: Vista/XP/2000, OS X, Linux
QuickTime 7, Flash 8

VTC Sign up & Benefits

  • Unlimited Access
  • 81,350 Video Tutorials (20,800 free)
  • Video Available as Flash or QuickTime
  • Over 782 Courses
  • $30 for One Month Access
  • Multi-User Discounts Available