How to: Search for a String in an Array of Strings (Visual Basic)
This example loops over each string in an array of strings to determine which ones contain the specified substring. For each match, the example displays the index of the substring in the string.
The Contains method indicates whether the string contains the specified substring.
The IndexOf method reports the location of the first character of the first occurrence of the substring. The index is 0-based, which means the first character of a string has an index of 0. If IndexOf does not find the substring, it returns -1.
This code example is also available as an IntelliSense code snippet. In the code snippet picker, it is located in Data Types - defined by Visual Basic. For more information, see How to: Insert IntelliSense Code Snippets.