From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

String.LeftBytes(count As Integer) As String

New in 2019r3

Supported for all project types and targets.

Returns the first count bytes of the String.


result = stringVariable.LeftBytes(count)

Part Type Description
result String The first count bytes of source. The encoding of result is the same as the source.
count Integer The number of bytes you wish to get from source.

If count is greater than the number of bytes in source, all bytes are returned.

stringVariable String Any variable of type String.


The LeftBytes 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 the actual characters rather than bytes, use the String.Left function.


This example uses the LeftBytes function to return the first 5 bytes from a string.

Var s As String = "Hello World"
s = s.LeftBytes(5) // returns "Hello"

See Also

AscB, ChrB, String.IndexOfBytes, String.Left, String.Bytes, String.MiddleBytes, String.RightBytes, MemoryBlock.LeftB functions.