Visual Basic: Split a string into separate words

Platform:Visual Basic
Task:Split a string into separate words
Discussion:
The below works. Also consider using the .Split() function
Example:
Private Function SplitStringIntoWords() As Integer
        Dim strComplete As String = "This-is a complete sentence"
        Dim strWords() As String
        Dim strSeparators() As Char = {" "c, "-"c}
        strWords = strComplete.Split(strSeparators)
        Dim i As Integer
        For i = 0 ToUBound(strWords)
            MessageBox.Show(strWords(i))
        Next
End Function
Back to Index