Write a Vb.net program to design the following form, allow the user to select radio buttons from Gender and Age Panel. After Selection appropriate CheckBox from Right Panel should be selected automatically. Display appropriate message into the MessageBox by clicking on Ok button.

Form:-


 

Program:-

Public Class slip13

    Dim male, female, flag As String

    ' to get RadioButton is checked or not

    Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged

        If RadioButton1.Checked = True Then

            male = "male"

            female = ""

        End If

    End Sub


    Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.CheckedChanged

        If RadioButton2.Checked = True Then

            female = "female"

            male = ""

        End If

    End Sub

' to checked the possible result of checkbox

    Private Sub RadioButton4_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton4.CheckedChanged

        If RadioButton4.Checked = True Then

            flag = 1

            CheckBox2.Checked = True

            CheckBox1.Checked = False

            CheckBox3.Checked = False

        End If

    End Sub


    Private Sub RadioButton3_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton3.CheckedChanged

        If RadioButton3.Checked = True Then

            flag = 2

            CheckBox1.Checked = True

            CheckBox3.Checked = True

            CheckBox2.Checked = False

        End If

    End Sub


   

    Private Sub RadioButton5_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton5.CheckedChanged

        If RadioButton5.Checked = True Then

            flag = 3

            CheckBox1.Checked = True

            CheckBox2.Checked = False

            CheckBox3.Checked = False

        End If

    End Sub

     ' To get Information through Msgbox

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

        Dim a As String

        a = TextBox1.Text

        If flag = 1 Then

            MsgBox("Name : " + a + " Gender: " + male + female + " msg : You can't drive")

        ElseIf flag = 2 Then

            MsgBox("Name : " + a + " Gender: " + male + female + " msg : You can drive and all right")

        ElseIf flag = 3 Then

            MsgBox("Name : " + a + " Gender: " + male + female + " msg : You can drive")

        End If

    End Sub

End Class


Output:-



Design:-

1) Take label, TextBox, Button, 3 Groupboxes, 5 RadioButtons, 3 Checkboxes on design form.
2) Set text on a Label, Button, Radio buttons, Checkboxes.




0 Comments