Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

VBScript Mid Function

VBScript Mid Function


VBScript reference manual Complete VBScript Reference Manual


The Mid function returns a specified number of characters from a string.

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

Syntax

Mid(string,start[,length])

Parameters Description
string Required. The string expression from which to return the characters.
start Required. Specifies the starting position. If set to a value greater than the number of characters in the string, an empty string ("") is returned.
length Optional. The number of characters to return.

Example

Example 1

Return 1 character, starting at position 1:

The example above produces the following output:

T

Try it »

Example 2

Return 15 characters, starting at position 1:

The example above produces the following output:

This is a beaut

Try it »

Example 3

Return all characters, starting at position 1:

The example above produces the following output:

This is a beautiful day!

Try it »

Example 4

Return all characters, starting at position 12:

The example above produces the following output:

eautiful day!

Try it »


VBScript reference manual Complete VBScript Reference Manual