ReadyBASIC
BASIC Language Reference Manual > Command and Function Reference >

RIGHT$ Function

Summary

Returns a string consisting of a certain number of characters from the right-hand side of a given string.

Syntax

RIGHT$(string expression, number of characters)

Remarks and Examples

The RIGHT$ function takes two parameters: a string to examine (we will call this string X$), and the number of characters to extract from the string X$ (we will call this number n).

RIGHT$ returns a string consisting of the rightmost n characters of the string X$, as shown in the following example:

10 A$ = "Baseball"
20 PRINT RIGHT$(A$, 4)
ball

If n is greater than the length of the string X$, then the entire string X$ is returned:

PRINT RIGHT$("Test", 10)
Test

If n is zero, an empty string is returned:

PRINT "(" & RIGHT$("Test", 0) & ")"
()

A negative value for n will cause an error at runtime.

See also: LEFT$, MID$




Copyright 2006-2008, Kevin Matz, All Rights Reserved.