VBScript Mid Functie

Definitie en gebruik

De Mid-functie kan een specifieke hoeveelheid tekens van een string retourneren.

Tip:Gebruik de Len-functie om het aantal tekens in een string te bepalen.

Syntax

Mid(string,start[,length])
Parameters Beschrijving
string Verplicht. De stringexpressie waaruit de tekens worden geretourneerd. Als de string Null bevat, wordt Null geretourneerd.
start Verplicht. Het startpunt. Als het ingesteld is op een waarde groter dan het aantal tekens in de string, wordt een lege string ("") geretourneerd.
length Optionele. Het aantal tekens dat je wilt retourneren. Als je het overslaat of als length meer is dan het aantal tekens in de tekst (inclusief het teken op de startpositie), wordt alle tekens van de startpositie tot het einde van de string geretourneerd.

Instance

Example 1

dim txt
txt="This is a beautiful day!"
document.write(Mid(txt,1,1))

Output:

T

Example 2

dim txt
txt="This is a beautiful day!"
document.write(Mid(txt,1,11))

Output:

This is a b

Example 3

dim txt
txt="This is a beautiful day!"
document.write(Mid(txt,1))

Output:

This is a beautiful day!

Example 4

dim txt
txt="This is a beautiful day!"
document.write(Mid(txt,10))

Output:

beautiful day!