Get Right String Method
The Get Right String method returns a portion of a string beginning at the end of the string. Note the following:
It accepts any type of string, including numeric values, and converts the input value to a string.
If the value that the string argument contains is NULL, then it returns a Null variant. For more information, see Variants.
If the value in the length argument is greater than the length of the string, then it returns the entire string.
Format
Right[$](string, length)
For information about the dollar sign, see Usage of the Dollar Sign.
The following table describes the arguments that you can use with this method.
Argument | Description |
---|---|
string |
A string or string expression that contains the characters to copy. |
length |
The number of characters to copy, beginning at the right-most position of the string and counting toward the left. |
Example
The following example searches for the BMP extension in a file name that the user enters. If it does not find the file, then it activates the Paintbrush application. It uses the Option Compare Text statement to accept uppercase or lowercase letters for the file name extension. For more information, see Set String Comparison Method:
Option Compare Text
Sub Button_Click
Dim filename as String
Dim x
filename ="d:\temp\picture.BMP"
extension = Right(filename,3)
If extension = "BMP" then
x = Shell("PBRUSH.EXE",1)
Sendkeys "%FO" & filename & "{Enter}", 1
Else
End If
End Sub