Siebel VB Language Reference > VB Language Reference >

Right Function

This standard VB function returns a portion of a string beginning at the end of the string.


Right[$](string, length)



A string or string expression containing the characters to copy


The number of characters to copy


A string of length length copied from the end of string.


If length is greater than the length of string, Right returns the whole string.

Right accepts any type of string, including numeric values, and converts the input value to a string.

The dollar sign ($) in the function name is optional. If it is included, the return type is string. Otherwise the function returns a variant of vartype 8 (string). If the value of string is NULL, a variant of vartype 1 (Null) is returned.


This example checks for the extension BMP in a filename entered by a user and activates the Paintbrush application if the file is found. Note that this uses the Option Compare Text statement to accept either uppercase or lowercase letters for the filename extension.

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

      End If
End Sub

Related Topics

InStr Function
Left Function
Len Function
LTrim Function
Mid Function
Mid Function
RTrim Function
Trim Function

Siebel VB Language Reference Copyright © 2006, Oracle. All rights reserved.