Tuesday, June 7, 2011

Split Words With Coma and sapace

Dim s As String = txtsearch.Text.ToString()
Dim s1 As String = s
' Split string based on spaces
Dim words As String() = s.Split(New Char() {","c})
s1 = s1.Replace(",", " ")
Dim words1 As String() = s1.Split(New Char() {" "c})

' Use For Each loop over words and display them
Dim word As String
For Each word In words
Console.WriteLine(word)
arrSTR.Add(word)
Next

For Each word In words1
Console.WriteLine(word)
arrSTR.Add(word)
Next

No comments:

Post a Comment