|
-
February 21st, 1999, 10:56 AM
#1
Help counting words in a textbox
Hi,
I'm trying to count the number of words in a textbox. I use the following code. But when I press the space bar twice, my word count is wrong because it's counting the space as a word. Can you please help me.
Dim oneChar As String
Dim i As Integer
Dim x As Integer
Dim howlong As Integer
howlong = Len(txtMaintext.Text) ' Parse through the characters in the string
For i = 1 To howlong
oneChar = Mid$(txtMaintext.Text, i, 1) ' Get a character
If oneChar = " " Then x = x + 1
txtNumWords.Text = x + 1 'This is the words count in the textbox
Next
-
March 1st, 1999, 01:23 AM
#2
Re: Help counting words in a textbox
When you encounter a space. Run a while loop to ignore whitespaces.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|