How to check a specific word in a selected list item?

I tried:

  • If ListBox1.Items.Contains ("myword") Then
  • If ListBox1.SelectedIndex = ListBox1.Items.IndexOf ("myword") Then
  • If ListBox1.SelectedItems.Item ("myword") Then

but no efect.

+4
source share
1 answer

Try something like this, listbox.items ListBox.ObjectCollection Property:

For Each i As Object In ListBox1.SelectedItems If CStr(i).Contains("myword") Then BackColor = Color.Blue ' Do your logic here, I just used setting the BackColor for a test End If Next 
+2
source

Source: https://habr.com/ru/post/1445902/


All Articles