DIAdem Help

Method: Split for VBS

  • Updated2024-09-12
  • 1 minute(s) read

Method: Split for VBS

Searches, in a text, for delimiters and generates a one-dimensional, zero-based array containing substrings.

vSplit = Object.Split(expression, [delimiter], [count], [compare])
ObjectVBS
Object with this method. You do not need to specify this object.
expressionVariant
Specifies the text you want to split.
[delimiter]Variant
Specifies the delimiter. If you do not specify a value, the Split method uses a blank (" ").
[count]Variant
Specifies the number of substrings to be returned. If you do not specify count, the Split method uses the value -1, and returns all substrings.
[compare]Variant
Specifies the type of comparison. Possible settings are vbBinaryCompare and vbTextCompare. If you do not specify compare, the Split method performs a binary comparison.
vSplitVariant
Receives a one-dimensional, zero-based array that contains substrings.

The following example splits the text DIAdemXisXgreat at the character X and generates an array that contains three strings:

Dim MyString, MyArray, i
MyString = "DIAdemXisXgreat"
MyArray = Split(MyString, "X", -1,vbTextCompare)
' MyArray(0) contains "DIAdem"
' MyArray(1) contains "is"
' MyArray(2) contains "great"

For i = 0 to UBound(MyArray)
  Call MsgBox(MyArray(i))
Next

See Also

Objects Overview

Related Topics

Filter | InStr | InStrB | InStrRev | Join | LCase | Left | LeftB | Len | LenB | LTrim | Mid | MidB | Replace | Right | RightB | RTrim | Space | Split | StrComp | String | StrReverse | Trim | UCase

Log in to get a better experience