VBScript Right Function

## VBScript Tutorial

VB HOME VB How to VB Variables VB Procedures VB Conditional VB Looping VB Summary

## VB Examples

VB Examples

## VB References

VB Functions VB Keywords

# VBScript Right Function

Complete VBScript Reference

The Right function returns a specified number of characters from the right side of a string.

Tip: Use the Len function to find the number of characters in a string.

Tip: Also look at the Left function.

### Syntax

Right(string,length)

Parameter | Description
--- | ---
string | Required. The string to return characters from
length | Required. Specifies how many characters to return. If set to 0, an empty string ("") is returned. If set to greater than or equal to the length of the string, the entire string is returned

## Examples

## Example 1

<script type="text/vbscript">
txt="This is a beautiful day!"
document.write(Right(txt,10))
</script>

The output of the code above will be:

tiful day!
Try it yourself »

## Example 2

Return the whole string:

<script type="text/vbscript">
txt="This is a beautiful day!"
x=Len(txt)
document.write(Right(txt,x))
</script>

The output of the code above will be:

This is a beautiful day!
Try it yourself »

Complete VBScript Reference

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE