Split Function
Updated: September 2009
Returns a zero-based, one-dimensional array containing a specified number of substrings.
Split(expression[, delimiter[, count[, compare]]])
The following example uses the Split function to fill an array from a string that uses "|" as a delimiter.
Dim MyString, MyArray, i MyString = "VBScript|is|fun!" MyArray = Split(MyString, "|", -1, 1) ' MyArray(0) contains "VBScript". ' MyArray(1) contains "is". ' MyArray(2) contains "fun!". For i = 0 to UBound(MyArray) MsgBox (MyArray(i)) Next
Example for WSH
Option Explicit
Dim sFutureArray, MyArray, x, sText
sFutureArray ="Some day this example will look boring to me"
MyArray = Split (sFutureArray, " ", -1, 1)sText = "The array holds " & UBound (MyArray) - LBound(MyArray) + 1 & " values. The values are the following:" & VBlf
For x = LBound(MyArray) to UBound (MyArray)
sText = sText & "MyArray(" & x & ")" & VBTab & MyArray(x) & VBlf
Next
WScript.Echo sText