Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Splitting a String on the ; Character

Status
Not open for further replies.

Kenny100

Technical User
Feb 6, 2001
72
NZ
Hi all - I need some help

I have strings of various sizes as follows:

thing1;thing2;thing3
thing1;thing2
thing1;thing2;thing3;thing4

Only one of these strings is used at a time but its length can vary. Could someone tell me how I can split this string on the ; character (the ; can then be discarded) and then populate an array with each of the newly formed strings (i.e. thing1 into array[0], thing2 into array[1], etc.).

I know JavaScript has a Split() function - does VBScript have something similar?

Regards,
Kenny.
 
It sure does:
Split(expression[, delimiter[, count[, compare]]])
So you would do something like:
arrMyArray = Split( strThingString, ";" )

Interestingly, this function is missing from VBA 5 but included in VBScript 5.

JAC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top