KirtSawaya
Technical User
I'm trying to count the number of words in a string. Note: A word is a sequence of characters seperated by a space.
I know it will not give me the exact number of words, but that is the guild lines I have to follow. Here is the code I use to total the words of any given array. But for some reason when I run the program, it freezes up. Here is the code somebody, please tell me what I'm doing wrong.
'Declares string to count words, sentences, and paragraphs
Dim strCounter As String
'checks to see if there is a space in the string
If mTextString.IndexOf(" ") <> -1 Then
strCounter = mTextString.Substring(mTextString.IndexOf(" "))
numWords += 1
End If
'Counts the total number of spaces in the string
While strCounter.Length > 0
If strCounter.IndexOf(".") <> -1 Then
strCounter = strCounter.Substring(strCounter.IndexOf(" "))
numWords += 1
End If
End While
Thank you for your help,
Kirt
I know it will not give me the exact number of words, but that is the guild lines I have to follow. Here is the code I use to total the words of any given array. But for some reason when I run the program, it freezes up. Here is the code somebody, please tell me what I'm doing wrong.
'Declares string to count words, sentences, and paragraphs
Dim strCounter As String
'checks to see if there is a space in the string
If mTextString.IndexOf(" ") <> -1 Then
strCounter = mTextString.Substring(mTextString.IndexOf(" "))
numWords += 1
End If
'Counts the total number of spaces in the string
While strCounter.Length > 0
If strCounter.IndexOf(".") <> -1 Then
strCounter = strCounter.Substring(strCounter.IndexOf(" "))
numWords += 1
End If
End While
Thank you for your help,
Kirt