Split Function

Returns a zero-based, one-dimensional array containing a specified number of substrings.

Syntax

Split(expression[, delimiter[, count[, compare]]])

Arguments:

  • Expression: Required. String expression containing substrings and delimiters. If expression is a zero-length string, Split returns an empty array, that is, an array with no elements and no data.
  • Delimiter: Optional. String character used to identify substring limits. If omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned.
  • Count: Optional. Number of substrings to be returned; -1 indicates that all substrings are returned. The default value is –1.
  • Compare: Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. The default value is 0.

    The compare argument can have the following values:

    Table 11-6 Comparison Constants and Descriptions

    Constant Value Description
    vbBinaryCompare 0 Perform a binary comparison
    vbTextCompare 1 Perform a textual comparison

The following example uses the Split function to return an array from a string. Output shows the values contained in the arr post Split.

Example 1:

arr=Split("Financial Management Business Script Language")
'Output : 
Financial
Management
Business
Script
Language

Example 2:

arr=Split("Financial Management, Business Script Language ",",")
'Output: 
Financial Management
 Business Script Language

Example 3:

arr=Split("SundayMondayTuesdayWEDNESDAYThursdayFridaySaturday","day")
'Output: 
Sun
Mon
Tues
WEDNESDAYThurs
Fri
Satur

Example 4:

arr= Split("SundayMondayTuesdayWEDNESDAYThursdayFridaySaturday","day",-1,1)
'Output: 
Sun
Mon
Tues
WEDNES
Thurs
Fri
Satur

Example 5:

arr=Split("Financial Management Business Script Language "," ", 2)
'Output: 
Financial
Management  Business Script Language