Visual Basic Language Reference  

Split Function

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

Function Split(
   ByVal Expression As String,
   Optional ByVal Delimiter As String = " ",
   Optional ByVal Limit As Integer = -1,
   Optional ByVal Compare As CompareMethod = CompareMethod.Binary
) As String()

Parameters

Expression
Required. String expression containing substrings and delimiters. If Expression is a zero-length string (""), the Split function returns an array with no elements and no data.
Delimiter
Optional. Single character used to identify substring limits. If Delimiter is 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.
Limit
Optional. Number of substrings to be returned; the default, –1, indicates that all substrings are returned.
Compare
Optional. Numeric value indicating the comparison to use when evaluating substrings. See Settings for values.

Settings

The Compare argument can have the following values:

Constant Description
Binary Performs a binary comparison
Text Performs a textual comparison

Example

The following example demonstrates the Split function:

Dim myString As String = "Look at these!"
' Returns ["Look", "at", "these!"]
Dim myArray() As String = Split(myString)

See Also

Join Function