ietprofessional
Programmer
Hi Everyone,
Can someone tell me how to get the count of selected values in ListBox?
Thanks!
Can someone tell me how to get the count of selected values in ListBox?
Thanks!
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
n = 0
If listContacts.SelectedIndex <> -1 Then
If listContacts.SelectionMode = ListSelectionMode.Single Then
txtCN.Text = listContacts.SelectedItem.Text
txtCID.Text = listContacts.SelectedItem.Value
Else
For i = listContacts.SelectedIndex To listContacts.Items.Count - 1
If listContacts.Items(i).Selected Then
n = n + 1
If n = 1 Then
s &= listContacts.Items(i).Text
r &= listContacts.Items(i).Value
Else
s &= ", " & listContacts.Items(i).Text
r &= ", " & listContacts.Items(i).Value
End If
End If
Next
txtCN.Text = s
txtCID.Text = r
End If
Dim i As Integer = 0
Dim li As ListItem
For Each li In ListBox1.Items
If li.Selected = True Then i += 1
Next
Response.Write(i)