Ritorno a dire che una volta che trovi l'indice dell'array che corrisponde alla tua ricerca *dovresti* aver trovato anche l'indice che ha quell'elemento nella listbox.
C#
private void button2_Click(object sender, EventArgs e)
{
int i=0;
foreach (string file in files)
{
if(file.Contains(textBox1.Text)){
listBox1.SelectedIndex = i;
return;
}
i++;
}
listBox1.SelectedIndex = -1;
}
in vb dovrebbe essere una roba del genere:
Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim i As Integer = 0
For Each file As String In files
If file.Contains(textBox1.Text) Then
listBox1.SelectedIndex = i
Return
End If
i += 1
Next
listBox1.SelectedIndex = -1
End Sub