Private Sub lstServers_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles lstServers.SelectedIndexChanged
Dim ctrl As ListBox = DirectCast(sender, ListBox)
' SelectedItem was set to Nothing beforehand
If ctrl.SelectedItem IsNot Nothing then
... do something ...
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)