string.Split Method

Divides a String variable value into a series of substrings based upon a specified separator character and returns the array of substrings.
...string.Split( separator_string )

Prerequisites

None

Parameters

separator_string

A required String expression.  The String expression can be a String variable, constant, function or method, or a concatenation of these String elements.  The first character of this expression defines the separator character.  For example, to split a line containing substrings separated by commas, this String should be set to ",".

Remarks

This method scans the value of the string variable searching for the specified separator character.  Each time the separator is found, the text after the previous separator (or from the start of the string if this is the first separator) and up to the new separator is taken as a substring and stored in a String array that is returned by this method. If the string variable does not contain a separator character, the entire contents of the string are copied to first element of the output array.

Examples

Dim stg_arr() As String            ' Create array string variable
Dim stg As String
stg = "1,2 ,this is the 3rd string"
stg_arr = stg.Split(",") ' stg_arr(0) = "1"
' stg_arr(1) = "2 "
' stg_arr(2) = "this is the 3rd string"

See Also

Strings