Search Tools Links Login

VB6 Tutorial 22: Option Button and Frame Controls


Have a look at some interesting features of the OptionButton and Frame controls in Visual Basic 6.

I'm discussing the frame control with option button in this lesson, because the Frame control is often used with option buttons when you want to have a couple of groups of the option button controls.

QuickHint:

Note that in the higher versions of Visual Basic and in some other languages, the term Radio Button is used instead of Option Button for the same control.

The OptionButton Control

This control lets you choose from several items among other in a list. This is one of the mostly frequently used controls in application developement. When you click on an OptionButton, it is switched to selected state or ON state, and all other option buttons in the group become unselected or OFF.

Example

Private Sub Command1_Click()
    If Option1.Value = True Then
        Print "Option1 is ON"
    Else
        Print "Option1 is OFF"
    End If
End Sub

Output

Simple option button program

When Option1.value = True then the Option Button is ON and when Option1.value = False then the Option button is OFF.

Example

Private Sub cmdCheck_Click()
    If optWindows.Value = True Then
        Print "Windows is selected"
    ElseIf optLinux.Value = True Then
        Print "Linux is selected"
    ElseIf optMac.Value = True Then
        Print "Mac is selected"
    End If
End Sub

Output

Example program with three option buttons

See the attached project OptionButtonExample for pre-made example of the option button functionality.

Frame

Frame is a container control as the Frame control is used as a container of other controls. The controls that are on the frame or contained in the frame are said to be the child controls. Use the Caption property to set the frame's title.

One of the most useful features of the Frame control is that when you move the frame, all the child controls also go with it. If you make the frame disabled or invisible, all the child controls also become disabled or invisible.

This container control is often used when you wish to select more than one OptionButton controls which are separated in a couple of groups like in the following sample program.

See the attached project FormatText for an example.

About this post

Posted: 2018-04-07
By: vb6boy
Viewed: 4,959 times

Categories

Visual Basic 6

VB6 Tutorial

Attachments

FormatText.zip
Posted: 4/7/2018 5:47:36 AM
Size: 1,269 bytes

OptionButtonExample.zip
Posted: 4/7/2018 5:46:54 AM
Size: 1,123 bytes


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.