Best Way to Implement Split Function in QTP VB script

Split Function

Purpose: This is another very common string manipulation function that you would find yourself using very often in your QTP Scripts. This function splits a string using a delimiter and returns a number of sub-strings stored in an array. For example, if you want to split the string “QuickTest Professional” using ” ” (blank space) as a delimiter, the split function would return 2 sub-strings – “QuickTest” and “Professional”. Both these sub-strings will be stored in an array. The first sub-string in index 0 of the array and the second sub-string in index 1 of the array.

Syntax: Split(String, Delimiter(optional), Count(optional), Compare(optional))


  • String is the text that you want to split.
  • Delimiter is the character or string using which you want to split the main string. If omitted, the space character (” “) is taken as the delimiter.
  • Count is the number of sub-strings that you want the function to return. The value -1 means that all the sub-strings will be returned.
  • Compare indicates the kind of sub-strings used while evaluating sub-strings. Value 0 indicates binary comparison and value 1 indicates textual comparison.