ASP Vbscript Right String Function

Updated on 21 Feb 2012,
Published on 02 Aug 2008

In ASP, vbscript Right string function returns the substring of specified length starting from the right side of a string. You can use also the vbscript Len function to get the number of characters in the string that returns the string length. Vbscript len function enables you to get the position of last character and retrieve the substring starting from the right side of specified string upto the character position greater than 0 and less than the length of the string.

Classic ASP VbScript String Functions Examples:

You can see the live samples and examples of Classic ASP VbScript String functions from the following links:

Syntax for ASP Vbscript Right String Function

Right(string, length)

Vbscript Right function accepts two parameters as shows in above syntax. You can use the vbscript Len function to specify the length parameter of Right string function.

  1. string: this parameter accepts the string value or string type variable name.
  2. length: this parameter accepts the number value to specify the length for the substring to be returned by the vbscript right function starting from the right side of a string specified in the string parameter.

Examples of ASP Vbscript Right String Function

Example 1
<%
Dim myString

myString = "Vbscript Right String Function"

Response.Write(Right(myString, 15))

Response.Write("<br />")

%>
Example 2
<%

myString = "Vbscript Right"

Dim length

' here vbscript for loop is used to pass the decreasing length dynamically for length parameter of Right string function.
For length = 1 To Len(myString)
    Response.Write(Right(myString, length))
    Response.Write("<br />")
Next

%>

Output:

You can see the output of above discussed code from the following link:

String Right Function

Continue to next tutorial: ASP Vbscript LCase String Function to learn how to convert the letters of a string to lowercase.

0 Responses to "ASP Vbscript Right String Function"
Leave a Comment
* required
* required
* will not be published
* optional
* hint: http://www.example.com
  • Subscribe via Email