Lesson 22

Radio Button

Radio buttons are used when the user must choose only one option from a group. Unlike checkboxes, radio buttons are mutually exclusive.

Lesson Overview

TopicRadioButton
FocusSingle Selection
Key SkillGrouping

What is a Radio Button?

A Radio Button allows users to select only one option from multiple choices.

  • Checkbox → Multiple selections
  • Radio Button → Only ONE selection

Common uses:

  • Gender selection
  • Payment method
  • Product choice
  • Survey questions

Example 22.1 – Select T-Shirt Color

User selects ONE color only.

Private Sub BtnConfirm_Click(...) Handles BtnConfirm.Click

Dim Tcolor As String

If RadioRed.Checked Then
    Tcolor = "Red Color"
    LblDisplay.ForeColor = Color.Red

ElseIf RadioGreen.Checked Then
    Tcolor = "Green Color"
    LblDisplay.ForeColor = Color.Green

Else
    Tcolor = "Yellow Color"
    LblDisplay.ForeColor = Color.Yellow
End If

LblDisplay.Text = Tcolor

End Sub

Only ONE option can be selected at any time.

Figure 22.1 – Radio Button Selection

Example 22.2 – Multiple Groups (Size + Color)

Radio buttons can be grouped using GroupBox. Each group allows ONE selection.

  • Group 1 → Size
  • Group 2 → Color
Dim TSize, TColor As String

If RadioXL.Checked Then
    TSize = "XL"
ElseIf RadioL.Checked Then
    TSize = "L"
ElseIf RadioM.Checked Then
    TSize = "M"
Else
    TSize = "S"
End If

If RadioRed.Checked Then
    TColor = "Red"
ElseIf RadioBlue.Checked Then
    TColor = "Blue"
Else
    TColor = "Beige"
End If

LblSize.Text = TSize
LblColor.Text = TColor

Figure 22.2 – Grouped Radio Buttons

Build on This Foundation

Continue to VB2026

After learning the basics of checkbox controls in VB2015, move to the newest VB2026 tutorial for a more modern VB.NET learning path.

Explore VB2026 →

Visual Basic Programming

Visual Basic Programming

Use this Top Release book to reinforce your tutorial learning with a more structured guide.

Key Takeaways:
  • Radio buttons allow only ONE selection
  • Use Checked property to detect selection
  • Use GroupBox for multiple categories
  • Ideal for forms and surveys

Next: Web Browser Control

Go to Lesson 23 →