List box data showing info in Label
I am working on the following problem: Have list box and label. In the list box when I highlight an item it should show in the label the assigned value. I am lloking to do it with Select Case statement.
This is what I have up to this moment:
Public Class PhoneForm
Inherits System.Windows.Forms.Form
Dim mstrIndex As String
Private Sub ExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitButton.Click
Me.Close()
End Sub
Private Sub PhoneForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strName() As String = {"Smith, Joe", "Jones, Mary", "Adkari, Joel", "Lin, Sue", "Li, Vicky"}
Dim intX As Integer
For intX = 0 To 4
Me.NameListBox.Items.Add(strName(intX))
Next intX
Me.NameListBox.SelectedIndex = 0
End Sub
Private Sub NameListBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles NameListBox.TextChanged
Me.ExtensionLabel.Text = "choose the name"
mstrIndex = Me.NameListBox.SelectedItem
Select Case mstrIndex
Case Is = "Smith, Joe"
Me.ExtensionLabel.Text = "3388"
Case Is = "Jones, Mary"
Me.ExtensionLabel.Text = "3356"
End Select
End Sub
End Class
I have a question:
WHY I AM NOT GETING VALEPrivate Sub NameListBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles NameListBox.TextChanged
Me.ExtensionLabel.Text = "choose the name"
mstrIndex = Me.NameListBox.SelectedItem
Select Case mstrIndex
Case Is = "Smith, Joe"
Me.ExtensionLabel.Text = "3388"
Case Is = "Jones, Mary"
Me.ExtensionLabel.Text = "3356"
End Select
End Sub
End ClassPrivate Sub NameListBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles NameListBox.TextChanged
Me.ExtensionLabel.Text = "choose the name"
mstrIndex = Me.NameListBox.SelectedItem
Select Case mstrIndex
Case Is = "Smith, Joe"
Me.ExtensionLabel.Text = "3388"
Case Is = "Jones, Mary"
Me.ExtensionLabel.Text = "3356"
End Select
End Sub
End Class
I have a question:
WHY I AM NOT GETTING VALUES SHOWN IN THE LABEL TEXT BOX?
WHAT AM I MISSING?
Thanks