Right Function


Right Function

Class

Microsoft.VisualBasic.Strings

Syntax

     Dim result As String = Right(str, length) 


str (required; String)

The string to be processed


length (required; Integer)

The number of characters to return from the rightmost portion of the string

Description

The Right function returns a string containing the rightmost length characters of str.

Usage at a Glance

  • If length is zero, a zero-length string is returned.

  • If length is greater than the length of str, str is returned.

  • If length is less than zero or is Nothing, an error is generated.

  • If str contains Nothing, Right returns Nothing.

  • Because of naming conflicts, you may have to preface this function with the name of the Microsoft.VisualBasic namespace.

  • Use the Len function to determine the total length of str.

Example

The following example uses the Right function to ensure that a directory path ends with a "\" character.

     Public Function ProperDirectory(origPath As String) As String        If (Right(origPath, 1) = "\") Then           Return origPath        Else           Return origPath & "\"        End If     End Function 

See Also

Left Function, Mid Function




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net