String.IndexOfBytes

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Method

String.IndexOfBytes(Optional start As Integer, find As String) As Integer

New in 2019r3

Supported for all project types and targets.

Returns the byte position of the first occurrence of a String inside another String. The first character is numbered 0.

Syntax

result=stringVariable.IndexOfBytes([start], find)

Part Type Description
result Integer The byte position of the first occurrence of find in source.

If the search string cannot be located in source, this returns -1.

start Integer Optional byte position from which to begin searching the source string. One is the default if omitted.
find String Required. String expression being sought.
stringVariable String Any variable of type String.

Notes

If the find string is not found within the source string, -1 (zero) is returned. IndexOfBytes is essentially case-sensitive since it treats the string as a series of raw bytes. It should be used instead of String.IndexOf when the string represents binary data.

If you need to find the character position of the find string within the source string, use the String.IndexOf function.

Examples

This example uses the IndexOfBytes function to locate a String within another string.

Dim s As String = "This is a test"
first = s.IndexOfBytes("test") // returns 10

See Also

AscB, ChrB, String.IndexOf, String.LeftBytes, String.Bytes, NthFieldB, String.MiddleBytes, String.RightBytes, SplitB functions.