VB6 Tutorial 22: Option Button and Frame Controls

Posted On 2018-04-07 by VB6Boy
Keywords: visual,basic,vb6,visualbasic,tutorial,basic,beginner
Tags: VB6 Tutorials Windows
Views: 56

Title Uploaded Size
FormatText.zip 4/7/2018 5:47:36 AM 1,269
OptionButtonExample.zip 4/7/2018 5:46:54 AM 1,123


Looking for the more of the VB6 Tutorial? Here is the tutorial index.

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.

Looking for the more of the VB6 Tutorial? Here is the tutorial index.


About the Author

has posted a total of 101 articles.


Comments On This Post

No comments on this post yet!


Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.


Your IP address is:54.158.30.219

Before you can post, you need to prove you are human. If you log in, this test goes away.


Code Links