Right$()

Syntax

Right$(Source$, Count)

Remarks

Returns the rightmost Count characters of Source$.

Example

This example prompts the user to enter his or her first and last name in an InputBox$() dialog box. By subtracting the position of the space (located between the first and last name) from the length of the full name, the instructions determine the number of characters after the space. Right$() is then able to retrieve the last name from the single string.


fullName$ = InputBox$("Please type your first and last name.")
length = Len(fullName$)
space = InStr(fullName$, " ")
lastName$ = Right$(fullName$, length - space)
MsgBox "Last name is " + lastName$ + "."

See Also

InStr(), Left$(), Len(), LTrim$(), Mid$(), RTrim$()