Funkce VBScript Mid
❮ Kompletní VBScript Reference
Funkce Mid vrací zadaný počet znaků z řetězce.
Tip: Pomocí funkce Len určete počet znaků v řetězci.
Syntax
Mid(string,start[,length])
Parameter | Description |
---|---|
string | Required. The string expression from which characters are returned |
start | Required. Specifies the starting position. If set to greater than the number of characters in string, it returns an empty string ("") |
length | Optional. The number of characters to return |
Příklady
Příklad 1
Vraťte 1 znak, počínaje pozicí 1:
<%
txt="This is a beautiful day!"
response.write(Mid(txt,1,1))
%>
Výstupem výše uvedeného kódu bude:
T
Příklad 2
Vraťte 15 znaků, počínaje pozicí 1:
<%
txt="This is a beautiful day!"
response.write(Mid(txt,1,15))
%>
Výstupem výše uvedeného kódu bude:
This is a beaut
Příklad 3
Vraťte všechny znaky, počínaje pozicí 1:
<%
txt="This is a beautiful day!"
response.write(Mid(txt,1))
%>
Výstupem výše uvedeného kódu bude:
This is a beautiful day!
Příklad 4
Vraťte všechny znaky, počínaje pozicí 12:
<%
txt="This is a beautiful day!"
response.write(Mid(txt,12))
%>
Výstupem výše uvedeného kódu bude:
eautiful day!
❮ Kompletní VBScript Reference