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

</div>

Method

# LenB

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

<div class="warning">

<div class="title">

Warning

</div>

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

</div>

## Description

Returns the number of bytes in the specified `string</api/data_types/string>`.

## Usage

*result*=**LenB**(*string*)

**OR**

*result*=*stringVariable*.**LenB**

| Part           | Type                               | Description                                            |
|----------------|------------------------------------|--------------------------------------------------------|
| result         | `Integer</api/data_types/integer>` | The number of bytes in *string*.                       |
| string         | `String</api/data_types/string>`   | Any valid string expression.                           |
| stringVariable | `String</api/data_types/string>`   | Any variable of type `String</api/data_types/string>`. |

## Notes

LenB treats string as a series of bytes, rather than a series of characters. It should be used when string represents binary data. If you need to know the number of characters in string rather than the number of bytes, use the `String.Length<string.length>` function.

## Sample code

This example uses the <span class="title-ref">LenB</span> function to return the number of bytes in a string.

``` xojo
Dim n As Integer
n = LenB("Hello world") ' returns 11

Dim s As String
s = "Hello World"
n = s.LenB ' returns 11
```

## Compatibility

All project types on all supported operating systems.

## See also

`String.AscByte<string.ascbyte>`, `String.ChrByte<string.chrbyte>`, `String.IndexOfBytes<string.indexofbytes>`, `String.Length<string.length>`, `String.MiddleBytes<string.middlebytes>`, `String.RightBytes<string.rightbytes>` functions.
