String Split : String Split « Data Types « VB.Net






String Split

String Split
   
Imports System
Imports System.Collections
 
Public Class MainClass

    Shared Sub Main(ByVal args As String())
             Dim s1 As String = "One,Two,Three "

             Const Space As Char = " "c
             Const Comma As Char = ","c

             Dim delimiters( ) As Char = {Space, Comma}

             Dim output As String = ""
             Dim ctr As Integer = 0

             Dim resultArray As String( ) = s1.Split(delimiters)

             Dim subString As String
             For Each subString In resultArray
                 ctr = ctr + 1
                 output &= ctr.ToString( )
                 output &= ": "
                 output &= subString
                 output &= Environment.NewLine
             Next subString
             Console.WriteLine(output)
    End Sub

End Class

           
         
    
    
  








Related examples in the same category

1.Split by ControlChars.Tab
2.String.Split Method (Char[])
3.String.Split Method (Char[], Int32)
4.String.Split Method (Char[], Int32, StringSplitOptions)
5.Split a string delimited by characters and return all elements
6.Split a string delimited by characters and return all non-empty elements
7.Split string into string and empty string
8.StringSplitOptions.RemoveEmptyEntries
9.Split a string delimited by another string and return all elements
10.Split the original string at the delimiter and return all non-empty elements
11.String.Split (Char[], StringSplitOptions) (System)_VB.htm
12.Split with string arrays
13.String.Split (String[], StringSplitOptions)