YouTip LogoYouTip

Func Split

VBScript Split Function | Newbie Tutorial

Newbie Tutorial -- Learning Technology, Chasing Dreams!

VBScript Tutorial

VB TutorialVB UsageVB VariablesVB ProceduresVB ConditionsVB LoopsVB SummaryVB ExamplesVB FunctionsVB Keywords

VBScript Examples VBScript Keywords

VBScript Split Function


Image 3: VBScript Reference Manual Complete VBScript Reference Manual


The Split function returns a zero-based one-dimensional array containing a specified number of substrings.

Syntax

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

Parameter Description
expression Required. A string expression containing substrings and delimiters.
delimiter Optional. The character used to identify substring boundaries. Default is the space character.
count Optional. The number of substrings to be returned. -1 indicates return all substrings.
compare Optional. Specifies the type of string comparison to use. Can take the following values: * 0 = vbBinaryCompare - Perform binary comparison * 1 = vbTextCompare - Perform text comparison

Examples

Example 1

a=Split(" is my favourite website") for each x in a document.write(x & "
") next

The above example outputs:



is

my

favourite

website
Try it Β»

Example 2

Using the delimeter parameter to split text:

a=Split("Brown cow, White horse, Yellow chicken",",") for each x in a document.write(x & "
") next

The above example outputs:

Brown cow

White horse

Yellow chicken 
Try it Β»

Example 3

Using delimeter parameter and count parameter to split text:

a=Split(" is my favourite website"," ",2) for each x in a document.write(x & "
") next

The above example outputs:



is my favourite website 
Try it Β»

Example 4

Using delimeter parameter with text comparison to split text:

a=Split("SundayMondayTuesdayWEDNESDAYThursdayFridaySaturday","day",-1,1) for each x in a document.write(x & "
") next

The above example outputs:

Sun

Mon

Tues

WEDNES

Thurs

Fri

Satur 
Try it Β»

Example 5

Using delimeter parameter with binary comparison to split text:

a=Split("SundayMondayTuesdayWEDNESDAYThursdayFridaySaturday","day",-1,0) for each x in a document.write(x & "
") next

The above example outputs:

Sun

Mon

Tues

WEDNESDAYThurs

Fri

Satur 
Try it Β»

Image 4: VBScript Reference Manual Complete VBScript Reference Manual

← Func UboundFunc Lbound β†’