top of page

The Code

 

 

 

Public Class Form88

    '## Radio Buttons - Visual Basic ##
    '## In Visual Basic 2013, the Radio Buttons operate differently from CheckBoxes ##
    '## While the CheckBoxes work independently and allow users to select ##
    '## One or More Items. The Radio Buttons are Mutually Exclusive. ##
    '## It means that the User can only choose One Item ##
    '## out of a Number of Choices from the Radio Buttons ##

    '## Group Boxes can be used to contain Radio Buttons(Menu) in [Form1.vb (Design)] Mode. ##
    '## Program is constructed by the  If... Then... Else decision making Format ##
    '## RadioButton#.Checked = False : Clears Value of Radio Button ##

    '## Nested Sub Rountines in Decision Statement - Count RadioButton Activation ##

    Dim Tcolor As String
    Dim
Count As Single
    Dim
Radio1Count, Radio2Count, Radio3Count, Button1RadioCount As Single

    Private Sub Button1Radio_Click(sender As Object, e As EventArgs) Handles Button1.Click

        If RadioButton1.Checked Then
           
Tcolor = "Red Color"
           
Label1.ForeColor = Color.Red


            '## SubRountine(1) ##
            '## Count Activation of Radio Button1 ##

            RadioCount1()
            

        ElseIf RadioButton2.Checked Then
           
Tcolor = "Green Color"
           
Label1.ForeColor = Color.Green


            '## Subrountine(2) ##
            '## Count Activation of Radio Button2 ##

            RadioCount2()

           

        Else
           
Tcolor = "Yellow Color"
           
Label1.ForeColor = Color.Yellow


            '## Subrountine(3) ##
            '## Count Activation of Radio Button3 ##

            RadioCount3()
           

        End If

        '## Tcolor Value assigned to Label1.Text ##
        Label1.Text = Tcolor
        Label1.BackColor = Color.LightGray

        '## Subroutine (4) ##
        '## Count all Radio Activations ##
        '## If... Then... Else... Decision Looping Procedure ##

        ButtonRadio1()

    End Sub

    '## Sub[1] ##
    Sub RadioCount1()
       
Radio1Count = Radio1Count + 1
       
LbRadio1.Text = Radio1Count
    End Sub

    '## Sub[2] ##
    Sub RadioCount2()
       
Radio2Count = Radio2Count + 1
       
LbRadio2.Text = Radio2Count
    End Sub

    '## Sub[3] ##
    Sub RadioCount3()
       
Radio3Count = Radio3Count + 1
       
LbRadio3.Text = Radio3Count
    End Sub

    '## Sub [4] ##
    Sub ButtonRadio1()
       
Button1RadioCount = Button1RadioCount + 1
       
LbButtonRadio.Text = Button1RadioCount

    End Sub


    Private Sub Button3ClearRadio_Click(sender As Object, e As EventArgs) Handles Button3.Click

        '## Clear RadioButton ##
        RadioButton1.Checked = False
        RadioButton2.Checked = False
        RadioButton3.Checked = False

        '## Clear Label Values ##
        Label1.Text = ""
       
LbRadio1.Text = ""
       
LbRadio2.Text = ""
       
LbRadio3.Text = ""
        LbButtonRadio.Text = ""


        '## Revert Variables back to Zero ##
        Radio1Count = 0
       
Radio2Count = 0
       
Radio3Count = 0
       
Button1RadioCount = 0

    End Sub

    Private Sub Button2CloseProgram_Click(sender As Object, e As EventArgs) Handles Button2.Click

        '## Close Program ##
        Form81.Show()

          Me.Hide()

    End Sub

End Class
 

 

 

 

Website Links-173.jpg
bottom of page