RIGHT$ function

Purpose

Return the rightmost n characters of a string.

Syntax

s$ = RIGHT$(string_expression, n&)

Remarks

If n& is positive, RIGHT$ returns the indicated number of characters from the string, starting from the right and working left.  If n& greater than the length of string_expression, all of string_expression is returned.

If n& is 0, RIGHT$ returns an empty string. If n& is negative, it is interpreted as (LEN(string_expression) - ABS(n&)). For example, RIGHT$("1234567890", -2) returns "34567890".

See also

EXTRACT$, INSTR, LEFT$, LTRIM$, MID$, REMOVE$, REPLACE, RTRIM$, TALLY, TRIM$, VERIFY

Example

' Demonstrate LEFT$ and RIGHT$ functions

DIM aString$, x$, n AS LONG

aString$ = "ABCDEFGHIJKLMNOP"

FOR n = 1 TO 14 STEP 2

  x$ = LEFT$(aString, n) + SPACE$(28 - n * 2) + RIGHT$(aString, n)

NEXT n