Name
Split Function
Syntax
Split(expression, [delimiter[,count[,compare]]])
expressionUse: Required
Data Type: String
A string to be broken up into multiple strings.
delimiterUse: Optional
Data Type: String
The character used to delimit the substrings in
expression.countuse: Optional
Data Type: Long
The number of strings to return.
compareUse: Optional
Data Type: Long
The method of comparison. Possible values are
vbBinaryCompareorvbTextCompare. Note that both are intrinsic VBScript constants; you do not have to define them yourself using theConststatement.
Return Value
A variant array consisting of the arguments passed into the function.
Description
Parses a single string containing delimited values into an array.
Rules at a Glance
If
delimiterisn’t found inexpression, Split returns the entire string in element 0 of the return array.If
delimiteris omitted, a space character is used as the delimiter.If
countis omitted or its value is -1, all strings are returned.The default comparison method is
vbBinaryCompare. Ifdelimiteris an alphabetic character, this setting controls whether the search for it inexpressionis case-sensitive (vbBinaryCompare) or not (vbTextCompare).Once
counthas been reached, the remainder of the string is placed, unprocessed, into the next element of the returned array.
Programming Tips and Gotchas
The variable you declare to assign the return value of
Filtermust be a simple variant, rather than a variant array. The following code is incorrect:' Incorrect Dim sArray( ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access