LEFT
Source: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgLeft Last revised: 2020-09-12
Returns the leftmost substring of a string.
Syntax
declare function Left ( byref str as const string, byval n as integer ) as string
declare function Left ( byref str as const wstring, byval n as integer ) as wstringUsage:
result = Left[$]( str, n )Parameters
- str — The source string.
- n — The number of characters to return from the source string.
Return Value
Returns the leftmost substring from str.
Description
Returns the leftmost n characters starting from the left (beginning) of str.
- If
stris empty, returns"". - If
n <= 0, returns"". - If
n > Len(str), returns the entire source string.
Examples
vb
Dim text As String = "hello world"
Print Left(text, 5)Output:
helloUnicode example:
vb
Dim text As WString * 20
text = "Привет, мир!"
Print Left(text, 6) 'displays "Привет"Platform Differences
- DOS does not support the wide-character string version of
Left.
Dialect Differences
- The string type suffix
$is required in the-lang qbdialect. - The string type suffix
$is optional in the-lang fblitedialect. - The string type suffix
$is ignored in the-lang fbdialect.
Differences from QB
- QB does not support Unicode.