InStrB

From Xojo Documentation
Jump to: navigation, search
Method

Returns the byte position of the first occurrence of a string inside another string. The first character is numbered 1.

Syntax

result=InStrB([start,] source, find)
OR
result=stringVariable.InStrB([start], find)Introduced 5.0

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, 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.

Notes

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.

Examples

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

Dim first As Integer
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

See Also

AscB, ChrB, InStr, LeftB, LenB, NthFieldB, MidB, RightB, SplitB, StrComp functions.

Personal tools
Namespaces

Variants
Actions
Main
Content
Starting Out
Dig Deeper
More Help
Toolbox
About