Skip to content

RIGHT

Source: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgRight Last revised: 2020-09-12

Returns the rightmost substring of a string.

Syntax

declare function Right ( byref str as const string, byval n as integer ) as string
declare function Right ( byref str as const wstring, byval n as integer ) as wstring

Usage:

result = Right[$]( str, n )

Parameters

  • str — The source string.
  • n — The substring length, in characters.

Return Value

Returns the rightmost substring from str.

Description

Returns the rightmost n characters starting from the right (end) of str.

  • If str is empty, returns "".
  • If n <= 0, returns "".
  • If n > Len(str), returns the entire source string.

Examples

vb
Dim text As String = "hello world"
Print Right(text, 5)

Output:

world

Unicode example:

vb
Dim text As WString * 20
text = "Привет, мир!"
Print Right(text, 5)  'displays " мир!"

Platform Differences

  • DOS does not support the wide-character string version of Right.

Dialect Differences

  • The string type suffix $ is required in the -lang qb dialect.
  • The string type suffix $ is optional in the -lang fblite dialect.
  • The string type suffix $ is ignored in the -lang fb dialect.

Differences from QB

  • QB does not support Unicode.

See Also

Translated from FreeBASIC official docs. Contact us for removal if infringed.
FreeBASIC is an open-source project, not affiliated with Microsoft