Name
Split Function
Syntax
Split(expression
, [delimiter
[,count
[,compare
]]])
expression
Use: Required
Data Type: String
A string to be broken up into multiple strings.
delimiter
Use: Optional
Data Type: String
The character used to delimit the substrings in
expression
.count
use: Optional
Data Type: Long
The number of strings to return.
compare
Use: Optional
Data Type: Long
The method of comparison. Possible values are
vbBinaryCompare
orvbTextCompare
. Note that both are intrinsic VBScript constants; you do not have to define them yourself using theConst
statement.
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
delimiter
isn’t found inexpression
, Split returns the entire string in element 0 of the return array.If
delimiter
is omitted, a space character is used as the delimiter.If
count
is omitted or its value is -1, all strings are returned.The default comparison method is
vbBinaryCompare
. Ifdelimiter
is an alphabetic character, this setting controls whether the search for it inexpression
is case-sensitive (vbBinaryCompare
) or not (vbTextCompare
).Once
count
has 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
Filter
must be a simple variant, rather than a variant array. The following code is incorrect:' Incorrect Dim sArray( ...
Get VBScript in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.