Pages

Tuesday 8 January 2013

Count Words

 Private Function CountWords() As Integer
        Dim strText As String = "It's a wonderful    world"
        Dim iCount As Integer


        Do While (strText.IndexOf(Space(2)) >= 0)
            strText = strText.Replace(Space(2), Space(1))
        Loop


        iCount = Split(strText, Space(1)).Length
        Return iCount
    End Function

No comments:

Post a Comment