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

</div>

Method

# MidB

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

<div class="warning">

<div class="title">

Warning

</div>

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

</div>

## Description

Returns a portion of a `string</api/data_types/string>`. The first character is numbered 1.

## Usage

*result*=**MidB**(*source*, *start* \[,*length*\])

**OR**

*result*=*stringVariable*.**MidB**(*start* \[,*length*\])

| Part           | Type                               | Description                                                                                                                                                                               |
|----------------|------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| result         | `String</api/data_types/string>`   | The portion of *source* from *start* and continuing for *length* characters or all remaining characters if *length* is not specified. The encoding of *result* is the same as the source. |
| source         | `String</api/data_types/string>`   | Required. The string from which bytes are returned.                                                                                                                                       |
| start          | `Integer</api/data_types/integer>` | Required. The position of the first byte to be returned.                                                                                                                                  |
| length         | `Integer</api/data_types/integer>` | Optional. The number of bytes to return from *source*.                                                                                                                                    |
| stringVariable | `String</api/data_types/string>`   | Any variable of type `String</api/data_types/string>`.                                                                                                                                    |

## Notes

MidB treats *source* as a series of bytes, rather than a series of characters. <span class="title-ref">MidB</span> should be used when *source* represents binary data. The encoding of the result is the same as the encoding of the source string.

If you need to extract characters rather than bytes, use the `String.Middle<string.middle>` function. To determine the number of bytes in a `string</api/data_types/string>`, use the `String.Bytes<string.bytes>` function.

## Sample code

These examples use the <span class="title-ref">MidB</span> function to return portions of a `string</api/data_types/string>`.

``` xojo
Dim s As String
s = MidB("This is a test", 6) ' returns "is a test"
s = MidB("This is a test", 11, 4) ' returns "test"

s = "This is a test"
s = s.MidB(11, 4)  ' returns "test"
```

## Compatibility

All project types on all supported operating systems.

## See also

`String.AscByte<string.ascbyte>`, `String.ChrByte<string.chrbyte>`, `String.IndexOfBytes<string.indexofbytes>`, `String.LeftBytes<string.leftbytes>`, `String.Bytes<string.bytes>`, `String.Middle<string.middle>`, `String.RightBytes<string.rightbytes>` functions.
