拆分函数返回一个数组,该数组包含基于定界符拆分的特定数量的值。
语法
Split(expression[,delimiter[,count[,compare]]])
- expression,一个必需参数。字符串表达式,可以包含带有定界符的字符串。
- delimiter,一个可选参数。参数,用于基于定界符转换为数组。
- count,一个可选参数。要返回的子字符串数,如果指定为-1,则返回所有子字符串。
- compare,一个可选参数。此参数指定要使用的比较方法。
- 0 = vbBinaryCompare-执行二进制比较
- 1 = vbTextCompare-执行文本比较
例
<!DOCTYPE html> <html> <body> <script language = "vbscript" type = "text/vbscript"> ' Splitting based on delimiter comma '$' a = Split("Red $ Blue $ Yellow","$") b = ubound(a) For i = 0 to b document.write("The value of array in " & i & " is :" & a(i)& "<br />") Next </script> </body> </html>
当以上代码另存为.HTML并在Internet Explorer中执行时,它会产生以下结果:
The value of array in 0 is :Red The value of array in 1 is : Blue The value of array in 2 is : Yellow
作者:terry,如若转载,请注明出处:https://www.web176.com/vbscript/1191.html