Returns the right most
n characters of the string parameter.
stringexpression
The string from which the right most characters are returned.
n
The number of characters that return. Must be a long integer.
Example
' The example uses the Right function to return the first of two
' words input by the user.
Sub Main()
Dim LWord, Msg, RWord, SpcPos, UsrInp ' Declare variables.
Msg = "Enter two words separated by a space."
UsrInp = InputBox(Msg) ' Get user input.
print UsrInp
SpcPos = InStr(1, UsrInp, " ") ' Find space.
If SpcPos Then
LWord = Left(UsrInp, SpcPos - 1) ' Get left word.
print "LWord: "; LWord
RWord = Right(UsrInp, Len(UsrInp) - SpcPos) ' Get right word.
Msg = "The first word you entered is " & LWord
Msg = Msg & "." & " The second word is "
Msg = "The first word you entered is <" & LWord & ">"
Msg = Msg & RWord & "."
Else
Msg = "You didn't enter two words."
End If
MsgBox Msg ' Display message.
End Sub