Private Sub btnCount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
btnCount.Click
Dim J As Integer
Dim cLast As Integer = txtEntry.TextLength - 1
Dim ThisChar As Char
Dim WordCount As Integer = 0
For J = 0 To cLast
ThisChar = txtEntry.Text.Chars(J)
If ThisChar = " " Then
WordCount += 1
End If
Private Sub btnCount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCount.Click
Dim J As Integer
Dim cLast As Integer = txtEntry.TextLength - 1
Dim ThisChar As Char
Dim WordCount As Integer = 0
For J = 0 To cLast
ThisChar = txtEntry.Text.Chars(J)
If ThisChar = " " Then
WordCount += 1
If J < cLast Then
If txtEntry.Text.Chars(J + 1) = " " Then
WordCount -= 1
End If
Else
WordCount -= 1
End If
End If
Next J
If cLast >= 0 Then
lblWordCount.Text = WordCount + 1
End If
End Sub
이 댓글을