Right$ Function

Returns a substring of the rightmost characters of a string.

Syntax
Right$(string, count)

Parameters

string
String variable or character string of up to 255 characters from which the rightmost characters are copied.
count
Specify the number of characters (a positive integer) to be copied from the end of the string, either as an expression or directly as a numeric value.

Return Values
Returns a string of the rightmost count characters from the character string specified by the user.

Description
Right$ returns the rightmost count characters of a string specified by the user. Right$ can return up to as many characters as are in the character string.

See Also
Asc, Chr$, InStr, Left$, Len, Mid$, Space$, Str$, Val

Right$ Statement Example
The example shown below shows a program which takes a part data string as its input and splits out the part number, part name, and part count.

Function SplitPartData(DataIn$ As String, ByRef PartNum$ As String, ByRef PartName$ As String, ByRef PartCount As Integer)

    PartNum$ = Left$(DataIn$, 10)

    DataIn$ = Right$(datain$, Len(DataIn$) - pos)
    pos = Instr(DataIn$, ",")

    PartName$ = Mid$(DataIn$, 11, 10)

    PartCount = Val(Right$(dataIn$, 5))

Fend

Some other example results from the Right$ instruction from the Command window.

> Print Right$("ABCDEFG", 2)
 FG

> Print Right$("ABC", 3)
 ABC