Use the split function to split the input.
result = sLine.split(" ")
Check this out:
Public Function CalculateAverage(ByVal str As String) As Integer
Dim TotalLetterCount As Integer = str.Replace(" ", "").Length
While str <> str.Replace(" ", " ")
str = str.Replace(" ", " ")
End While
Dim words() As String = str.Split(" ")
Dim average As Integer = TotalLetterCount / words.Length
Return average
End Function
This function calculates the average.
it also contains the total nr of words (words.length)
and the words variable is a list of the words.
In your example you are not utilizing the built in functions of the language.