Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save oviniciusfeitosa/cb60cbe5331b7134f33f to your computer and use it in GitHub Desktop.
Save oviniciusfeitosa/cb60cbe5331b7134f33f to your computer and use it in GitHub Desktop.
Get the SelectedValues from ListBox - VB.NET
Public Shared Function getSelectedValuesFromListBox(ByVal objListBox As ListBox) As String
Dim listOfIndices As List(Of Integer) = objListBox.GetSelectedIndices().ToList()
Dim values As String = String.Empty
For Each indice As Integer In listOfIndices
values &= "," & objListBox.Items(indice).Value
Next indice
If Not String.IsNullOrEmpty(values) Then
values = values.Substring(1)
End If
Return values
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment