Средняя функция VBScript
❮ Полный справочник VBScript
Функция Mid возвращает указанное количество символов из строки.
Совет: Используйте функцию Len, чтобы определить количество символов в строке.
Синтаксис
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 |
Примеры
Пример 1
Вернуть 1 символ, начиная с позиции 1:
<%
txt="This is a beautiful day!"
response.write(Mid(txt,1,1))
%>
Вывод кода выше будет:
T
Пример 2
Вернуть 15 символов, начиная с позиции 1:
<%
txt="This is a beautiful day!"
response.write(Mid(txt,1,15))
%>
Вывод кода выше будет:
This is a beaut
Пример 3
Вернуть все символы, начиная с позиции 1:
<%
txt="This is a beautiful day!"
response.write(Mid(txt,1))
%>
Вывод кода выше будет:
This is a beautiful day!
Пример 4
Вернуть все символы, начиная с позиции 12:
<%
txt="This is a beautiful day!"
response.write(Mid(txt,12))
%>
Вывод кода выше будет:
eautiful day!
❮ Полный справочник VBScript