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

</div>

Method

# LeftB

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

<div class="warning">

<div class="title">

Warning

</div>

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

</div>

## Description

Returns the first n bytes in a source `string</api/data_types/string>`.

## Usage

*result*=**LeftB**(*source*, *count*)

OR

*result*=*stringVariable*.**LeftB**(*count*)

| Part           | Type                               | Description                                                                              |
|----------------|------------------------------------|------------------------------------------------------------------------------------------|
| result         | `String</api/data_types/string>`   | The first *count* bytes of *source*. The encoding of *result* is the same as the source. |
| source         | `String</api/data_types/string>`   | The source string from which to get the bytes.                                           |
| count          | `Integer</api/data_types/integer>` | The number of bytes you wish to get from *source*.                                       |
| stringVariable | `String</api/data_types/string>`   | Any variable of type `String</api/data_types/string>`.                                   |

## Notes

The <span class="title-ref">LeftB</span> function returns bytes from the source string starting from the left side (as the name implies). The encoding of the result is the same as the encoding of the source string.

If you need to read characters rather than bytes, use the `String.Left<string.left>` function.

## Sample code

This example uses the <span class="title-ref">LeftB</span> function to return the first 5 bytes from a string.

``` xojo
Dim s As String
s = LeftB("Hello World", 5) ' returns "Hello"
s = "Hello World"
s = s.LeftB(5) ' returns "Hello"
```

## Compatibility

All project types on all supported operating systems.

## See also

`String.AscByte<string.ascbyte>`, `String.ChrByte<string.chrbyte>`, `String.IndexOfBytes<string.indexofbytes>`, `String.Left<string.left>`, `String.Bytes<string.bytes>`, `String.MiddleBytes<string.middlebytes>`, `String.RightBytes<string.rightbytes>` functions.
