Split Function (VB6)

Named Arguments

No

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: Variant

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: VbCompareMethod constant

The method of comparison. Possible values are vbBinaryCompare, vbTextCompare, or vbDatabaseCompare.

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

  • The returned array is always base regardless of any Option Base setting.

  • If delimiter isn't found in expression, Split returns the entire string in element of the return array.

  • If delimiteris 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.

  • 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 array you declare to assign the return value of Split must be a dynamic, single-dimension string array, or a variant.

  • Strings are written to the returned array in the order in which they appear in expression.

See Also

Join Function

Get VB & VBA in a Nutshell: The Language 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.