<div class="meta" robots="noindex">

</div>

Method

# InStrB

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2019r2. Please use `String.IndexOfBytes<string.indexofbytes>` as a replacement.

</div>

## Description

Returns the byte position of the first occurrence of a `string</api/data_types/string>` inside another `string</api/data_types/string>`. The first character is numbered 1.

## Usage

result=**InStrB**(\[start,\] source, find)

**OR**

*result*=*stringVariable*.**InStrB**(\[*start*\], *find*)

| Part           | Type                               | Description                                                                                            |
|----------------|------------------------------------|--------------------------------------------------------------------------------------------------------|
| result         | `Integer</api/data_types/integer>` | The byte position of the first occurrence of *find* in *source*.                                       |
| start          | `Integer</api/data_types/integer>` | Optional byte position from which to begin searching the source string. One is the default if omitted. |
| source         | `String</api/data_types/string>`   | Required. `String</api/data_types/string>` expression being searched.                                  |
| find           | `String</api/data_types/string>`   | Required. `String</api/data_types/string>` expression being sought.                                    |
| stringVariable | `String</api/data_types/string>`   | Any variable of type `String</api/data_types/string>`.                                                 |

## Notes

If the find string is not found within the source string, 0 (zero) is returned. <span class="title-ref">InStrB</span> is case-sensitive; it treats source as a series of raw bytes. It should be used instead of `String.IndexOf<string.indexof>` 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 `String.IndexOf<string.indexof>` function.

## Sample code

This example uses the <span class="title-ref">InStrB</span> function to locate a `string</api/data_types/string>` within another string.

``` xojo
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
```

## Compatibility

All project types on all supported operating systems.

## See also

`String.AscByte<string.ascbyte>`, `String.ChrByte<string.chrbyte>`, `String.IndexOf<string.indexof>`, `String.LeftBytes<string.leftbytes>`, `String.Bytes<string.bytes>`, `MemoryBlock</api/language/memoryblock>`, `String.MiddleBytes<string.middlebytes>`, `String.RightBytes<string.rightbytes>`, `String.SplitBytes<string.splitbytes>`, `String.Compare<string.compare>` functions.
