CitectVBA Programming Reference > CitectVBA Function Reference > String Functions > Right

Right

Returns the right most Num characters of Str. The required Str argument is a String expression from which the rightmost characters are returned. If Str contains Null, Null is returned.

The required Num argument is a Variant (Long) numeric expression indicating how many characters to return. If 0, a zero-length string (" ") is returned. If greater than or equal to the number of characters in string, the entire string is returned.

Note: To determine the number of characters in a string, use the Len function.

Syntax

Right(Str, Num)

Str:

A string or expression that can represent a valid text value.

Num:

An Integer or expression representing a valid numeric value.

Return Value

The Right function returns a variant containing a string data type.
The Right$ function returns a string.

Related Functions

InStr | Left, Left$ | Mid

Example

Dim strGreeting as String
Dim strTest
strGreeting = "Hello World"
strTest = Right(strGreeting, 1) ' Returns "d"
strTest = Right(strGreeting, 5) ' Returns "World"
strTest = Right(strGreeting, 20) ' Returns "Hello World"