Write a Vb.net program to design the following form, select the question number from combo box that question will be displayed into textbox and the options for that question will be displayed on four radio buttons, select option and click on submit button result should be displayed in another textbox.
Form:
Public Class slip14
Private Sub slip14_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("Question1")
ComboBox1.Items.Add("Question2")
ComboBox1.Items.Add("Question3")
RadioButton1.Visible = False
RadioButton2.Visible = False
RadioButton3.Visible = False
RadioButton4.Visible = False
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If ComboBox1.SelectedItem() = "Question1" Then
If RadioButton1.Checked = True Then
TextBox2.Text = "Answer is Correct."
Else
TextBox2.Text = "Answer is Wrong."
End If
End If
If ComboBox1.SelectedItem() = "Question2" Then
If RadioButton2.Checked = True Then
TextBox2.Text = "Answer is Correct."
Else
TextBox2.Text = "Answer is Wrong."
End If
End If
If ComboBox1.SelectedItem() = "Question3" Then
If RadioButton4.Checked = True Then
TextBox2.Text = "Answer is Correct."
Else
TextBox2.Text = "Answer is Wrong."
End If
End If
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
RadioButton1.Visible = True
RadioButton2.Visible = True
RadioButton3.Visible = True
RadioButton4.Visible = True
If ComboBox1.SelectedItem() = "Question1" Then
TextBox1.Text = "What is capital of India?"
TextBox2.Text = ""
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
RadioButton1.Text = "New Delhi"
RadioButton2.Text = "Mumbai"
RadioButton3.Text = "Pune"
RadioButton4.Text = "Chennai"
ElseIf ComboBox1.SelectedItem() = "Question2" Then
TextBox1.Text = "What is Capital of USA?"
TextBox2.Text = ""
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
RadioButton1.Text = "New York"
RadioButton2.Text = "Washington DC"
RadioButton3.Text = "California"
RadioButton4.Text = "Georgia"
ElseIf ComboBox1.SelectedItem() = "Question3" Then
TextBox1.Text = "what is capital of Germany?"
TextBox2.Text = ""
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
RadioButton1.Text = "Frankfurt"
RadioButton2.Text = "Washington DC"
RadioButton3.Text = "Hamburg"
RadioButton4.Text = "Berlin"
End If
End Sub
End Class
Output:-
1) Take labels, ComboBox, Button, 4 Radiobuttons, TextBox on Design form.
2) Set text on Labels, Radiobuttons.
0 Comments