History |
InStr (strings)
Purpose
Returns the position of the first occurrence of one string (the search string) within another (the source string).
If the search string is found within the source string, this function returns an integer that indicates the character position of the first occurrence of the string.
If the search string is not found, InStr returns 0.
If the search string is a zero-length string, the start value is returned.
Syntax
InStr ([Start,] SourceString, SearchString [Case])
Example
Sub Main()
Dim s As String, Ioc As Integer
s = "the quick brown fox jumps over the lazy dog"
Ioc = InStr(s, "fox")
If Ioc<>0 Then
Print "The string 'fox' was first found at character position "; Ioc
Else
Print "The string 'fox' was not found in the search string"
End If
End Sub
| ||||||