DESCRIPTION:
PROPERTIES:
CODEING:
When user selects a country name from combo box,corresponding President/Head name should be displayed in another combo box.Click the button textbox text add to combo box.
Label1 | |
Text | COUNTRY NAME |
Label1 | |
Text | PRESIDENT NAME |
ComboBox1 | |
Text | COUNTRY |
Items | INDIA |
U.S.A | |
U.A.E | |
RUSSIA | |
ComboBox2 | |
Text | PRESIDENT|HEAD |
Items | Narendra Modi |
Donald Trump | |
Khalifa bin Zayed Al Nahyan | |
Vladimir Putin | |
TextBox1 | |
Text | (Empty) |
Button1 | |
Text | ADD COUNTRY |
Public Class Form1
Dim country As String
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
ComboBox2.SelectedIndex = ComboBox1.SelectedIndex
Label2.Text = "PRESIDENT OF " & ComboBox1.Text
End Sub
Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
ComboBox1.SelectedIndex = ComboBox2.SelectedIndex
Label2.Text = "PRESIDENT OF " & ComboBox1.Text
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Button1.Text = "ADD COUNTRY" And Not TextBox1.Text = "" Then
country = TextBox1.Text
Button1.Text = "HEAD OF " & country
TextBox1.Clear()
ElseIf Not TextBox1.Text = "" Then
ComboBox2.Items.Add(TextBox1.Text)
ComboBox1.Items.Add(country)
Button1.Text = "ADD COUNTRY"
TextBox1.Clear()
End If
End Sub
End Class
DESIGNING:Dim country As String
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
ComboBox2.SelectedIndex = ComboBox1.SelectedIndex
Label2.Text = "PRESIDENT OF " & ComboBox1.Text
End Sub
Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
ComboBox1.SelectedIndex = ComboBox2.SelectedIndex
Label2.Text = "PRESIDENT OF " & ComboBox1.Text
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Button1.Text = "ADD COUNTRY" And Not TextBox1.Text = "" Then
country = TextBox1.Text
Button1.Text = "HEAD OF " & country
TextBox1.Clear()
ElseIf Not TextBox1.Text = "" Then
ComboBox2.Items.Add(TextBox1.Text)
ComboBox1.Items.Add(country)
Button1.Text = "ADD COUNTRY"
TextBox1.Clear()
End If
End Sub
End Class
Comments
Post a Comment