How to VB.NET String.Split()

The VB.Net Split() extracts the substrings from the given string that are delimited by the separator parameter, and returns those substrings as elements of an array.


If your String contains "dd-mm-yy", split on the "-" character to get an array of: "dd" "mm" "yy".

If the separator parameter is null or contains no characters, white space characters are assumed to be the delimiters.

Syntax :

Public Function Split(ByVal ParamArray separator() As Char) As String()


separator - the given delimiter


An array of Strings delimited by one or more characters in separator

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click

        Dim str As String
        Dim strArr() As String
        Dim count As Integer
        str = " split test"
        strArr = str.Split(" ")
        For count = 0 To strArr.Length - 1

    End Sub
End Class

When you execute this programme , you will get "" "split" "test" in separate messagebox.

 VB.NET String - Related Contents

 VB.NET String - Related Programs