Word Count in Text Box

# Thread: Word Count in Text Box

1. JAB
Member
Join Date
Dec 1969
Posts
36

## Word Count in Text Box

Hello I am trying to do a word count in a message count that will read all words and no white space. This is the code I have found this far but not been able to get it to work without errors.<BR><BR>Dim oneChar As String<BR>Dim i As Integer<BR>Dim x As Integer<BR>Dim howlong As Integer<BR>howlong = Len(txtMaintext.Text) &#039 Parse through the characters in the string <BR><BR><BR>For i = 1 To howlong <BR>oneChar = Mid(txtMaintext.Text, i, 1) &#039 Get a character <BR><BR><BR>If oneChar = " " Then x = x + 1 <BR>now = x + 1 &#039This is the words count in the textbox <BR>Next <BR>End If

2. Junior Member
Join Date
Dec 1969
Posts
9

## RE: Word Count in Text Box

For i = 1 To howlong <BR> oneChar = Mid(trim(txtMaintext.Text), i, 1) &#039 Get a character <BR> If oneChar = " " Then <BR> now = now + 1 &#039This is the words count in the textbox <BR> End If <BR>Next <BR>

3. Junior Member
Join Date
Dec 1969
Posts
9

## RE: Word Count in Text Box

For i = 1 To howlong <BR> oneChar = Mid(trim(txtMaintext.Text), i, 1) &#039 Get a character <BR> If oneChar = " " Then <BR> x= x + 1 &#039This is the words count in the textbox <BR> End If <BR>Next <BR><BR>x=x+1<BR>

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## RE: Word Count in Text Box

The *second* answer by "Jumbo Burrito" is the correct one.<BR><BR>You can&#039t use "now" the way you were doing because<BR>"Now" is a built in keyword (the function that returns <BR>the current date and time).<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•