Problem: I have this code to run a word counter. But I have a problem when I hit the enter key, it doesn't give me any output of how many chars or words.
Code:
''' <summary>
''' Returns Word Count base on spaces
''' </summary>
''' <param name="textToParse"></param>
''' <returns>Integer = Word Count</returns>
''' <remarks></remarks>
Private Function CountWords(ByVal textToParse As String) As Integer
Dim intWords = 0
If textToParse.Trim.Length > 0 Then
Dim strWords() As String = textToParse.Split(" "c)
intWords = strWords.Length
End If
Return intWords
End Function
Private Sub txtWords_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtWords.TextChanged
UpdateDisplay()
'lblResults.Text = "The results are: " & CountCharacters(txtWords.Text).ToString("N0")
End Sub
Private Sub UpdateDisplay()
If radCountChars.Checked Then
lblResults.Text = "Character Count is: " & CountCharacters(txtWords.Text).ToString("N0") & " chars."
Else
lblResults.Text = "Word Count is: " & CountWords(txtWords.Text).ToString("N0") & " words."
End If
End Sub
Comment