I have the following code inside a buttons click event. How can I get the value of .valuemember? The messageboxes from the SelectedIndexChanged events display blank.
Dim i As Long
For i = 0 To 3
With cbo1
.DisplayMember = "value" & CStr(i + i)
.ValueMember = CStr(i + i)
.Items.Add("value" & CStr(i + i))
End With
With ListBox1
.DisplayMember = "value" & CStr(i + i)
.ValueMember = CStr(i + i)
.Items.Add("value" & CStr(i + i))
End With
Next
Private Sub cbo1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo1.SelectedIndexChanged
MsgBox(cbo1.SelectedValue)
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
MsgBox(ListBox1.SelectedValue)
End Sub
Dim i As Long
For i = 0 To 3
With cbo1
.DisplayMember = "value" & CStr(i + i)
.ValueMember = CStr(i + i)
.Items.Add("value" & CStr(i + i))
End With
With ListBox1
.DisplayMember = "value" & CStr(i + i)
.ValueMember = CStr(i + i)
.Items.Add("value" & CStr(i + i))
End With
Next
Private Sub cbo1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo1.SelectedIndexChanged
MsgBox(cbo1.SelectedValue)
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
MsgBox(ListBox1.SelectedValue)
End Sub