From Xojo Documentation
|You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!|
| This item was deprecated in version 2019r2.
Please use String.IndexOfBytes as a replacement.
result=InStrB([start,] source, find)
|result||Integer||The byte position of the first occurrence of find in source.
If the search string cannot be located in source, InStrB returns 0.
|start||Integer||Optional byte position from which to begin searching the source string. One is the default if omitted.|
|source||String||Required. String expression being searched.|
|find||String||Required. String expression being sought.|
|stringVariable||String||Any variable of type String.|
If the find string is not found within the source string, 0 (zero) is returned. InStrB is case-sensitive; it treats source as a series of raw bytes. It should be used instead of InStr when the string represents binary data or when your application will run in a one-byte character set (such as the US system) and you want case-sensitivity.
If you need to find the character position of the find string within the source string, use the InStr function.
This example uses the InStrB function to locate a string within another string.
first = InStrB("This is a test", "T") // returns 1
first = InStrB("This is a test", "t") // returns 11
first = InStrB("This is a test", "is") // returns 3
first = InStrB(4, "This is a test", "is") // returns 6
first = InStrB("This is a test", "tester") // returns 0
first = InStrB("This Is a test", "Is") // returns 6
Dim s As String = "This is a test"
first = s.InStrB("test") // returns 11