Splitexpression[ delimiter[ count[ compare

This function is the counterpart of the JoinQ function. It returns a one-dimensional array containing a number of substrings. The expression argument is a string that contains the original string that will be broken into smaller strings, and the optional delimiter argument is a character delimiting the substrings in the original string. If delimiter is omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned. The count argument is also optional, and it determines the number of substrings to be returned. If it's —1, all substrings are returned. The last argument, compare, is also optional and indicates the kind of comparison to use when evaluating substrings. Its value can be one of the CompareMethod enumeration's members (Table 8).

Let's say you have declared a string variable with the following path name:

path = "c:\win\desktop\DotNet\Examples\Controls"

The Split() function can extract the path's components and assign them to the parts array, if called as follows:

parts = Sp1it("c:\win\desktop\DotNet\Examp1es\Contro1s", "\") To display the parts of the path, set up a loop such as the following:

For i = 0 To parts.GetUpperBound(O)

Conso1e.WriteLine(parts(i)) Next

0 0

Post a comment