I have a Textbox and a MultiSelect listbox with following values
When i enter the values in the text box and click on search it should select the particular values in the listbox. I'm Using the below code
Private Sub Search_Click()
Dim str As String
Dim c As Collection
Dim strArray() As String
Dim intcnt As Integer
str = txtAnswer.Value
strArray = Split(str, ",")
For Each itm In strArray
lstAnswer.Selected (itm)= True
Next
End Sub
I want to get the below result
But It selects the index instead of values. for Example
How to select the values instead of index?
Private Sub Search_Click()
Dim ItM As String
Dim c As Collection
Dim strArray() As String
Dim intcnt As Integer
strArray = Split(txtAnswer.Value, ",")
With lstAnswer
For Each ItM In strArray
For i = 0 To .ListCount - 1
If .List(i) <> ItM Then
Else
.Selected(i) = True
Exit For
End If
Next i
Next ItM
End With
End Sub